[gcov] Increment counters with atomicrmw if -fsanitize=thread
authorFangrui Song <maskray@google.com>
Fri, 28 Aug 2020 23:32:35 +0000 (16:32 -0700)
committerFangrui Song <maskray@google.com>
Fri, 28 Aug 2020 23:32:35 +0000 (16:32 -0700)
commitb5ef137c11b1cc6ae839ee75b49233825772bdd0
tree5892889b13b18a59195cb59bf6588241ea20718e
parent141c8475b693e245388cf7a4ac9ec17303988700
[gcov] Increment counters with atomicrmw if -fsanitize=thread

Without this patch, `clang --coverage -fsanitize=thread` may fail spuriously
because non-atomic counter increments can be detected as data races.
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/code-coverage-tsan.c [new file with mode: 0644]
llvm/include/llvm/Transforms/Instrumentation.h
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/test/Transforms/GCOVProfiling/atomic-counter.ll [new file with mode: 0644]