[llvm] r351247 - [SanitizerCoverage] Don't create comdat for interposable functions.
Matt Morehouse via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 15 13:21:01 PST 2019
Author: morehouse
Date: Tue Jan 15 13:21:01 2019
New Revision: 351247
URL: http://llvm.org/viewvc/llvm-project?rev=351247&view=rev
Log:
[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
Added:
llvm/trunk/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll
Modified:
llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=351247&r1=351246&r2=351247&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Tue Jan 15 13:21:01 2019
@@ -568,7 +568,7 @@ GlobalVariable *SanitizerCoverageModule:
*CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage,
Constant::getNullValue(ArrayTy), "__sancov_gen_");
- if (TargetTriple.supportsCOMDAT())
+ if (TargetTriple.supportsCOMDAT() && !F.isInterposable())
if (auto Comdat =
GetOrCreateFunctionComdat(F, TargetTriple, CurModuleUniqueId))
Array->setComdat(Comdat);
Added: llvm/trunk/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll?rev=351247&view=auto
==============================================================================
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll (added)
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll Tue Jan 15 13:21:01 2019
@@ -0,0 +1,37 @@
+; Test that interposable symbols do not get put in comdats.
+; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -mtriple x86_64-linux-gnu -S | FileCheck %s
+; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -mtriple x86_64-windows-msvc -S | FileCheck %s
+
+define void @Vanilla() {
+entry:
+ ret void
+}
+
+define linkonce void @LinkOnce() {
+entry:
+ ret void
+}
+
+define weak void @Weak() {
+entry:
+ ret void
+}
+
+declare extern_weak void @ExternWeak()
+
+define linkonce_odr void @LinkOnceOdr() {
+entry:
+ ret void
+}
+
+define weak_odr void @WeakOdr() {
+entry:
+ ret void
+}
+
+; CHECK: define void @Vanilla() comdat {
+; CHECK: define linkonce void @LinkOnce() {
+; CHECK: define weak void @Weak() {
+; CHECK: declare extern_weak void @ExternWeak()
+; CHECK: define linkonce_odr void @LinkOnceOdr() comdat {
+; CHECK: define weak_odr void @WeakOdr() comdat {
More information about the llvm-commits
mailing list