[all-commits] [llvm/llvm-project] 5624e8: [tsan] Respect !nosanitize metadata and remove gco...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Aug 24 22:31:24 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5624e86ae0fb259c6069d1cc7d5eaa24402f9134
      https://github.com/llvm/llvm-project/commit/5624e86ae0fb259c6069d1cc7d5eaa24402f9134
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-08-24 (Thu, 24 Aug 2023)

  Changed paths:
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/test/CodeGen/code-coverage-tsan.c
    M clang/test/Driver/fprofile-update.c
    M llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
    M llvm/test/Instrumentation/ThreadSanitizer/do-not-instrument-memory-access.ll

  Log Message:
  -----------
  [tsan] Respect !nosanitize metadata and remove gcov special case

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




More information about the All-commits mailing list