[tsan] Don't instrument __llvm_gcov_global_state_pred or __llvm_gcda*

r274801 did not go far enough to allow gcov+tsan to cooperate. With this
commit it's possible to run the following code without false positives:

  std::thread T1(fib), T2(fib);
  T1.join(); T2.join();

llvm-svn: 276015
This commit is contained in:
Vedant Kumar 2016-07-19 20:16:08 +00:00
parent 24547108d6
commit 57faf2d208
2 changed files with 16 additions and 2 deletions

View File

@ -272,8 +272,9 @@ static bool shouldInstrumentReadWriteFromAddress(Value *Addr) {
return false;
}
// Check if the global is in a GCOV counter array.
if (GV->getName().startswith("__llvm_gcov_ctr"))
// Check if the global is private gcov data.
if (GV->getName().startswith("__llvm_gcov") ||
GV->getName().startswith("__llvm_gcda"))
return false;
}

View File

@ -13,6 +13,8 @@ target triple = "x86_64-apple-macosx10.9"
@__llvm_gcov_ctr = internal global [1 x i64] zeroinitializer
@__llvm_gcov_ctr.1 = internal global [1 x i64] zeroinitializer
@__llvm_gcov_global_state_pred = internal global i32 0
@__llvm_gcda_foo = internal global i32 0
define i32 @test_gep() sanitize_thread {
entry:
@ -42,5 +44,16 @@ entry:
ret i32 undef
}
define void @test_load() sanitize_thread {
entry:
%0 = load i32, i32* @__llvm_gcov_global_state_pred
store i32 1, i32* @__llvm_gcov_global_state_pred
%1 = load i32, i32* @__llvm_gcda_foo
store i32 1, i32* @__llvm_gcda_foo
ret void
}
; CHECK-NOT: {{call void @__tsan_write}}
; CHECK: __tsan_init