]> granicus.if.org Git - llvm/commitdiff
[tsan] Try harder to not instrument gcov counters
authorVedant Kumar <vsk@apple.com>
Thu, 7 Jul 2016 22:45:28 +0000 (22:45 +0000)
committerVedant Kumar <vsk@apple.com>
Thu, 7 Jul 2016 22:45:28 +0000 (22:45 +0000)
GCOVProfiler::emitProfileArcs() can create many variables with names
starting with "__llvm_gcov_ctr", so llvm appends a numeric suffix to
most of them. Teach tsan about this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274801 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/ThreadSanitizer.cpp
test/Instrumentation/ThreadSanitizer/do-not-instrument-memory-access.ll

index a23b1ddf8252a3f97626f1b5efe2b3d50b622ba6..dcb62d3ed1b51c3aea5166b6b2269a794f0d1863 100644 (file)
@@ -272,8 +272,8 @@ static bool shouldInstrumentReadWriteFromAddress(Value *Addr) {
         return false;
     }
 
-    // Check if the global is in the GCOV counters array.
-    if (GV->getName() == "__llvm_gcov_ctr")
+    // Check if the global is in a GCOV counter array.
+    if (GV->getName().startswith("__llvm_gcov_ctr"))
       return false;
   }
 
index e734a382a9c1abfdd47d69d456e714948052176c..db12ec7daec343225ba0eeeba2ab0af891efaf67 100644 (file)
@@ -12,6 +12,7 @@ target triple = "x86_64-apple-macosx10.9"
 @__profc_test_bitcast_foo = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 
 @__llvm_gcov_ctr = internal global [1 x i64] zeroinitializer
+@__llvm_gcov_ctr.1 = internal global [1 x i64] zeroinitializer
 
 define i32 @test_gep() sanitize_thread {
 entry:
@@ -23,6 +24,10 @@ entry:
   %1 = add i64 %gcovcount, 1
   store i64 %1, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_gcov_ctr, i64 0, i64 0)
 
+  %gcovcount.1 = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_gcov_ctr.1, i64 0, i64 0)
+  %2 = add i64 %gcovcount.1, 1
+  store i64 %2, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_gcov_ctr.1, i64 0, i64 0)
+
   ret i32 1
 }