Skip to content

Commit 19ff35c

Browse files
committedJan 15, 2019
[SanitizerCoverage] Don't create comdat for interposable functions.
Summary: Comdat groups override weak symbol behavior, allowing the linker to keep the comdats for weak symbols in favor of comdats for strong symbols. Fixes the issue described in: https://bugs.chromium.org/p/chromium/issues/detail?id=918662 Reviewers: eugenis, pcc, rnk Reviewed By: pcc, rnk Subscribers: smeenai, rnk, bd1976llvm, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D56516 llvm-svn: 351247
1 parent 4a22fb1 commit 19ff35c

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed
 

‎llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ GlobalVariable *SanitizerCoverageModule::CreateFunctionLocalArrayInSection(
568568
*CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage,
569569
Constant::getNullValue(ArrayTy), "__sancov_gen_");
570570

571-
if (TargetTriple.supportsCOMDAT())
571+
if (TargetTriple.supportsCOMDAT() && !F.isInterposable())
572572
if (auto Comdat =
573573
GetOrCreateFunctionComdat(F, TargetTriple, CurModuleUniqueId))
574574
Array->setComdat(Comdat);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
; Test that interposable symbols do not get put in comdats.
2+
; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -mtriple x86_64-linux-gnu -S | FileCheck %s
3+
; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -mtriple x86_64-windows-msvc -S | FileCheck %s
4+
5+
define void @Vanilla() {
6+
entry:
7+
ret void
8+
}
9+
10+
define linkonce void @LinkOnce() {
11+
entry:
12+
ret void
13+
}
14+
15+
define weak void @Weak() {
16+
entry:
17+
ret void
18+
}
19+
20+
declare extern_weak void @ExternWeak()
21+
22+
define linkonce_odr void @LinkOnceOdr() {
23+
entry:
24+
ret void
25+
}
26+
27+
define weak_odr void @WeakOdr() {
28+
entry:
29+
ret void
30+
}
31+
32+
; CHECK: define void @Vanilla() comdat {
33+
; CHECK: define linkonce void @LinkOnce() {
34+
; CHECK: define weak void @Weak() {
35+
; CHECK: declare extern_weak void @ExternWeak()
36+
; CHECK: define linkonce_odr void @LinkOnceOdr() comdat {
37+
; CHECK: define weak_odr void @WeakOdr() comdat {

0 commit comments

Comments
 (0)
Please sign in to comment.