[llvm] r281952 - [sanitizer-coverage] add comdat to coverage guards if needed
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 19 17:16:55 PDT 2016
Author: kcc
Date: Mon Sep 19 19:16:54 2016
New Revision: 281952
URL: http://llvm.org/viewvc/llvm-project?rev=281952&view=rev
Log:
[sanitizer-coverage] add comdat to coverage guards if needed
Added:
llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.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=281952&r1=281951&r2=281952&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Mon Sep 19 19:16:54 2016
@@ -669,6 +669,8 @@ void SanitizerCoverageModule::InjectCove
auto GuardVar = new GlobalVariable(
*F.getParent(), Int64Ty, false, GlobalVariable::LinkOnceODRLinkage,
Constant::getNullValue(Int64Ty), "__sancov_guard." + F.getName());
+ if (auto Comdat = F.getComdat())
+ GuardVar->setComdat(Comdat);
// TODO: add debug into to GuardVar.
GuardVar->setSection(SanCovTracePCGuardSection);
auto GuardPtr = IRB.CreatePointerCast(GuardVar, IntptrPtrTy);
Added: llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll?rev=281952&view=auto
==============================================================================
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll (added)
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll Mon Sep 19 19:16:54 2016
@@ -0,0 +1,13 @@
+; Test that the coverage guards have proper 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"
+$Foo = comdat any
+; Function Attrs: uwtable
+define linkonce_odr void @Foo() comdat {
+entry:
+ ret void
+}
+
+; CHECK: @__sancov_guard.Foo = linkonce_odr global i64 0, section "__sancov_guards", comdat($Foo)
+
More information about the llvm-commits
mailing list