[sanitizer-coverage] make sure asan does not instrument coverage guards (reported...
authorKostya Serebryany <kcc@google.com>
Tue, 15 Nov 2016 21:12:50 +0000 (21:12 +0000)
committerKostya Serebryany <kcc@google.com>
Tue, 15 Nov 2016 21:12:50 +0000 (21:12 +0000)
llvm-svn: 287030

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

index 73881fa..031effb 100644 (file)
@@ -514,7 +514,7 @@ void SanitizerCoverageModule::CreateFunctionGuardArray(size_t NumGuards,
   ArrayType *ArrayOfInt32Ty = ArrayType::get(Int32Ty, NumGuards);
   FunctionGuardArray = new GlobalVariable(
       *CurModule, ArrayOfInt32Ty, false, GlobalVariable::PrivateLinkage,
-      Constant::getNullValue(ArrayOfInt32Ty), "__sancov_guard");
+      Constant::getNullValue(ArrayOfInt32Ty), "__sancov_gen_");
   if (auto Comdat = F.getComdat())
     FunctionGuardArray->setComdat(Comdat);
   FunctionGuardArray->setSection(SanCovTracePCGuardSection);
index f5fa326..baf4dc1 100644 (file)
@@ -1,5 +1,7 @@
 ; Test that the coverage guards have proper comdat
-; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S | FileCheck %s
+; RUN: opt < %s -sancov                    -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; Make sure asan does not instrument __sancov_gen_
+; RUN: opt < %s -sancov -asan -asan-module -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
@@ -9,4 +11,10 @@ entry:
   ret void
 }
 
-; CHECK: @__sancov_guard = private global [1 x i32] zeroinitializer, section "__sancov_guards", comdat($Foo)
+define linkonce_odr void @Bar() {
+entry:
+  ret void
+}
+
+; CHECK: @__sancov_gen_ = private global [1 x i32] zeroinitializer, section "__sancov_guards", comdat($Foo)
+; CHECK: @__sancov_gen_.1 = private global [1 x i32] zeroinitializer, section "__sancov_guards"