This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Respect !nosanitize metadata and remove gcov special case
ClosedPublic

Authored by MaskRay on Aug 20 2023, 8:39 PM.

Details

Summary

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.

Diff Detail

Event Timeline

MaskRay created this revision.Aug 20 2023, 8:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2023, 8:39 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
MaskRay requested review of this revision.Aug 20 2023, 8:39 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 20 2023, 8:39 PM
Enna1 accepted this revision.Aug 21 2023, 1:49 AM
This revision is now accepted and ready to land.Aug 21 2023, 1:49 AM
This revision was landed with ongoing or failed builds.Aug 24 2023, 10:31 PM
This revision was automatically updated to reflect the committed changes.