tsan: de-hardcode number of unused bits in trace events
authorDmitry Vyukov <dvyukov@google.com>
Tue, 16 Nov 2021 08:18:00 +0000 (09:18 +0100)
committerDmitry Vyukov <dvyukov@google.com>
Tue, 16 Nov 2021 15:00:14 +0000 (16:00 +0100)
commitc971f989ee9e1356308933e809ecbbbc5976c581
tree91a3f712d1d0fc25089d50e2a00e9aaf3124f99a
parentfa24d58279cf9a3e5a5ac894194808f4c1ad01f3
tsan: de-hardcode number of unused bits in trace events

Precisely specifying the unused parts of the bitfield is critical for
performance. If we don't specify them, compiler will generate code to load
the old value and shuffle it to extract the unused bits to apply to the new
value. If we specify the unused part and store 0 in there, all that
unnecessary code goes away (store of the 0 const is combined with other
constant parts).

I don't see a good way to ensure we cover all of u64 bits with fields.
So at least introduce named kUnusedBits consts and check that bits
sum up to 64.

Depends on D113978.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113979
compiler-rt/lib/tsan/rtl/tsan_trace.h