Difference between gcc and clang tsan on combined read/write

92 views
Skip to first unread message

Anders Waldenborg

unread,
May 8, 2021, 4:40:57 AM5/8/21
to thread-sanitizer

Hi,

Have noticed a difference between what clang and gcc emits when istrumenting something that is an inplace operation such as "*anintpointer |= 1".

gcc emits both __tsan_read4 and __tsan_write4  calls while clang only emits a call to __tsan_write4


Is this an intentional optimization that is done in the clang/llvm implementation (and thus a missed optimization in gcc)? Or is this an inaccuracy in the clang/llvm implementation?

(we have our own runtime that currently just borrows the tsan instrumentation to trace memory accesses for other reasons. This is why we have notice this)

Dmitry Vyukov

unread,
May 8, 2021, 4:43:36 AM5/8/21
to Anders Waldenborg, thread-sanitizer
Hi Anders,

This is an intentional optimization in clang and a missed optimization in gcc.
Reply all
Reply to author
Forward
0 new messages