
Certain instrumentations set the !nosanitize metadata for inserted instructions, which are generally not interested for sanitizers. Skip tsan instrumentation like we do for asan (D126294)/msan/hwasan. -fprofile-arcs instrumentation has data race unless -fprofile-update=atomic is specified. Let's remove the the `__llvm_gcov` special case from commit 0222adbcd25779a156399bcc16fde9f6d083a809 (2016) as the racy instructions have the !nosanitize metadata. (-fprofile-arcs instrumentation does not use `__llvm_gcda` as global variables.) ``` std::atomic<int> c; void foo() { c++; } int main() { std::thread th(foo); c++; th.join(); } ``` Tested that `clang++ --coverage -fsanitize=thread a.cc && ./a.out` does not report spurious tsan errors. Also remove the default CC1 option -fprofile-update=atomic for -fsanitize=thread to make options more orthogonal. Reviewed By: Enna1 Differential Revision: https://reviews.llvm.org/D158385
12 lines
512 B
C
12 lines
512 B
C
/// -fprofile-update=atomic requires the (potentially concurrent) counter updates to be atomic.
|
|
// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fprofile-update=atomic \
|
|
// RUN: -coverage-notes-file=/dev/null -coverage-data-file=/dev/null -o - | FileCheck %s
|
|
|
|
// CHECK-LABEL: void @foo()
|
|
/// Two counters are incremented by __tsan_atomic64_fetch_add.
|
|
// CHECK: atomicrmw add ptr @__llvm_gcov_ctr{{.*}} monotonic, align 8
|
|
// CHECK-NEXT: atomicrmw sub ptr
|
|
|
|
_Atomic(int) cnt;
|
|
void foo(void) { cnt--; }
|