TSan instrumentation functions for atomic stores, loads, and cmpxchg work on integer value types. This patch adds casts before calling TSan instrumentation functions in cases where the value is a pointer.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
How did it work without these casts all that time?.. Is it the case that programs that used atomic<void*> failed to compile?
test/Instrumentation/ThreadSanitizer/atomic.ll | ||
---|---|---|
1196 ↗ | (On Diff #49681) | Are you sure that we don't run these tests on 32-bit platforms? It will fail on 32-bit platform, right? |
How did it work without these casts all that time?.. Is it the case that programs that used atomic<void*> failed to compile?
Looks like clang's IRGen inserts the bit casts in this case. (It's possible that it was written that way because the atomic loads and stores emission went through the same interface as emission for other atomics that were restricted to int values.) However, other front ends (such as Swift) do not insert the bit casts. Since these IR instructions are defined to work with pointer types, LLVM should support them even if the clang IRGen does not emit such code.
The cmpxchg was extended to allow pointer type operands on Feb 19th (see r261281) .
test/Instrumentation/ThreadSanitizer/atomic.ll | ||
---|---|---|
1196 ↗ | (On Diff #49681) | I believe this will not fail since the test specifies the target layout, where pointers are 64 bits long: target datalayout = "e-p:64:64:64-... "p[n]:<size>:<abi>:<pref> This specifies the size of a pointer and its <abi> and <pref>erred alignments for address space n. All sizes are in bits. The address space, n, is optional, and if not specified, denotes the default address space 0. The value of n must be in the range [1,2^23)." |
Eager to see Tsan for Swift!
LGTM
test/Instrumentation/ThreadSanitizer/atomic.ll | ||
---|---|---|
1196 ↗ | (On Diff #49681) | ack |