[llvm] r283924 - [sanitizer-coverage] use private linkage for coverage guards, delete old commented-out code.

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 11 12:36:50 PDT 2016


Author: kcc
Date: Tue Oct 11 14:36:50 2016
New Revision: 283924

URL: http://llvm.org/viewvc/llvm-project?rev=283924&view=rev
Log:
[sanitizer-coverage] use private linkage for coverage guards, delete old commented-out code.

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
    llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll

Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=283924&r1=283923&r2=283924&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Tue Oct 11 14:36:50 2016
@@ -502,17 +502,17 @@ bool SanitizerCoverageModule::runOnFunct
   InjectTraceForGep(F, GepTraceTargets);
   return true;
 }
-void SanitizerCoverageModule::CreateFunctionGuardArray(size_t NumGuards, Function &F) {
+void SanitizerCoverageModule::CreateFunctionGuardArray(size_t NumGuards,
+                                                       Function &F) {
   if (!Options.TracePCGuard) return;
   HasSancovGuardsSection = true;
   ArrayType *ArrayOfInt32Ty = ArrayType::get(Int32Ty, NumGuards);
   FunctionGuardArray = new GlobalVariable(
-      *CurModule, ArrayOfInt32Ty, false, GlobalVariable::LinkOnceODRLinkage,
-      Constant::getNullValue(ArrayOfInt32Ty), "__sancov_guard." + F.getName());
+      *CurModule, ArrayOfInt32Ty, false, GlobalVariable::PrivateLinkage,
+      Constant::getNullValue(ArrayOfInt32Ty), "__sancov_guard");
   if (auto Comdat = F.getComdat())
     FunctionGuardArray->setComdat(Comdat);
   FunctionGuardArray->setSection(SanCovTracePCGuardSection);
-  FunctionGuardArray->setVisibility(GlobalValue::HiddenVisibility);
 }
 
 bool SanitizerCoverageModule::InjectCoverage(Function &F,
@@ -687,14 +687,6 @@ void SanitizerCoverageModule::InjectCove
     IRB.CreateCall(SanCovTracePC); // gets the PC using GET_CALLER_PC.
     IRB.CreateCall(EmptyAsm, {}); // Avoids callback merge.
   } else if (Options.TracePCGuard) {
-    //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);
     auto GuardPtr = IRB.CreateIntToPtr(
         IRB.CreateAdd(IRB.CreatePointerCast(FunctionGuardArray, IntptrTy),
                       ConstantInt::get(IntptrTy, Idx * 4)),

Modified: llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll?rev=283924&r1=283923&r2=283924&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll (original)
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll Tue Oct 11 14:36:50 2016
@@ -9,4 +9,4 @@ entry:
   ret void
 }
 
-; CHECK: @__sancov_guard.Foo = linkonce_odr hidden global [1 x i32] zeroinitializer, section "__sancov_guards", comdat($Foo)
+; CHECK: @__sancov_guard = private global [1 x i32] zeroinitializer, section "__sancov_guards", comdat($Foo)




More information about the llvm-commits mailing list