This is an archive of the discontinued LLVM Phabricator instance.

tsan: use DCHECK instead of CHECK in atomic functions
ClosedPublic

Authored by dvyukov on Aug 3 2021, 10:08 AM.

Details

Summary

Atomic functions are semi-hot in profiles.
The CHECKs verify values passed by compiler
and they never fired, so replace them with DCHECKs.

Diff Detail

Event Timeline

dvyukov created this revision.Aug 3 2021, 10:08 AM
dvyukov requested review of this revision.Aug 3 2021, 10:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2021, 10:08 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Aug 3 2021, 10:09 AM
This revision is now accepted and ready to land.Aug 3 2021, 10:09 AM
melver accepted this revision.Aug 3 2021, 10:45 AM

Turns out that Clang turns invalid orders into 0==relaxed: https://godbolt.org/z/nrz44zoMn

GCC doesn't seem to do so and happily passes the invalid order to the runtime.

It may still be a valid debugging aid to users if we ever expect Clang to change that. Other than that, one would hope that the incorrect memory order would eventually manifest in a reported data race.

Turns out that Clang turns invalid orders into 0==relaxed: https://godbolt.org/z/nrz44zoMn

GCC doesn't seem to do so and happily passes the invalid order to the runtime.

It may still be a valid debugging aid to users if we ever expect Clang to change that. Other than that, one would hope that the incorrect memory order would eventually manifest in a reported data race.

Yes, clang now handles this in the compiler. I don't want to introduce runtime overhead only for gcc that is not doing the same.

This revision was automatically updated to reflect the committed changes.