[TSAN] Add option to allow instrumenting reads of reads-before-writes
authorDmitry Vyukov <dvyukov@google.com>
Fri, 15 May 2020 12:14:18 +0000 (14:14 +0200)
committerDmitry Vyukov <dvyukov@google.com>
Fri, 15 May 2020 14:08:44 +0000 (16:08 +0200)
commit151ed6aa38a3ec6c01973b35f684586b6e1c0f7e
tree48a09a2aa50948a6f4fe8951c2722b10f00d1232
parentfb1c55b57dda134866803bdf3cdda2cc57a7dc5c
[TSAN] Add option to allow instrumenting reads of reads-before-writes

Add -tsan-instrument-read-before-write which allows instrumenting reads
of reads-before-writes.

This is required for KCSAN [1], where under certain configurations plain
writes behave differently (e.g. aligned writes up to word size may be
treated as atomic). In order to avoid missing potential data races due
to plain RMW operations ("x++" etc.), we will require instrumenting
reads of reads-before-writes.

[1] https://github.com/google/ktsan/wiki/KCSAN

Author: melver (Marco Elver)
Reviewed-in: https://reviews.llvm.org/D79983
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/test/Instrumentation/ThreadSanitizer/read_before_write.ll