[TSan] Add option for emitting compound read-write instrumentation
authorMarco Elver <elver@google.com>
Fri, 17 Jul 2020 06:53:56 +0000 (08:53 +0200)
committerMarco Elver <elver@google.com>
Fri, 17 Jul 2020 08:24:20 +0000 (10:24 +0200)
commit785d41a261d136b64ab6c15c5d35f2adc5ad53e3
tree19e34830048bb4b3f2ac067d1f7d7952443d8aca
parent0db3ac33540ee6a846d68472a439385fbf219fb6
[TSan] Add option for emitting compound read-write instrumentation

This adds option -tsan-compound-read-before-write to emit different
instrumentation for the write if the read before that write is omitted
from instrumentation. The default TSan runtime currently does not
support the different instrumentation, and the option is disabled by
default.

Alternative runtimes, such as the Kernel Concurrency Sanitizer (KCSAN)
can make use of the feature. Indeed, the initial motivation is for use
in KCSAN as it was determined that due to the Linux kernel having a
large number of unaddressed data races, it makes sense to improve
performance and reporting by distinguishing compounded operations. E.g.
the compounded instrumentation is typically emitted for compound
operations such as ++, +=, |=, etc. By emitting different reports, such
data races can easily be noticed, and also automatically bucketed
differently by CI systems.

Reviewed By: dvyukov, glider

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D83867
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/test/Instrumentation/ThreadSanitizer/read_before_write.ll