[PATCH] D56516: [SanitizerCoverage] Don't create comdat for weak functions.

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 10 09:20:40 PST 2019


morehouse updated this revision to Diff 181076.
morehouse added a comment.

- Add test.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56516/new/

https://reviews.llvm.org/D56516

Files:
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/weak-symbol-nocomdat.ll


Index: llvm/test/Instrumentation/SanitizerCoverage/weak-symbol-nocomdat.ll
===================================================================
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/weak-symbol-nocomdat.ll
@@ -0,0 +1,17 @@
+; Test that weak functions do not get put in a comdat.
+; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+; Function Attrs: uwtable
+define weak void @Foo() {
+entry:
+  ret void
+}
+
+define void @Bar() {
+entry:
+  ret void
+}
+
+; CHECK-NOT: define weak void @Foo() comdat
+; CHECK: define void @Bar() comdat
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -577,7 +577,7 @@
       *CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage,
       Constant::getNullValue(ArrayTy), "__sancov_gen_");
 
-  if (TargetTriple.supportsCOMDAT())
+  if (TargetTriple.supportsCOMDAT() && !F.hasWeakLinkage())
     if (auto Comdat =
             GetOrCreateFunctionComdat(F, TargetTriple, CurModuleUniqueId))
       Array->setComdat(Comdat);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56516.181076.patch
Type: text/x-patch
Size: 1355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190110/a4c180f3/attachment.bin>


More information about the llvm-commits mailing list