Change the LLVM instrumentation pass to match the corresponding changes (D23369) to external/compiler-rt/lib/msan i.e., accesses the MsanTLSSlot using either TLS_SLOT_TSAN (on Android) or original __thread variables (on non-Android).
Details
Diff Detail
Event Timeline
This emits the TLS access code inline:
- using Intrinsic::thread_pointer and TLS_SLOT_TSAN if on Android
- using the regular GlobalVariable::InitialExecTLSModel if on non-Android
to match the changes in D23369.
i.e., compared to the previous diff, this avoids the function calls in the generated code, and the copious #if SANITIZER_ANDROID throughout this source file.
Transforms/Instrumentation/MemorySanitizer.cpp | ||
---|---|---|
498 ↗ | (On Diff #67586) | This would emit a call to llvm.thread.pointer for each TLS access. Please check that they are optimized out and the final assembly does not do the extra loads of TLS_SLOT_TSAN - and if it does, change the IR to call thread.pointer only once per function. |
505 ↗ | (On Diff #67586) | As per the comment in the compiler-rt review, we need to keep the old TLS variables on non-Android. |
510 ↗ | (On Diff #67586) | These should be named constants. |
Matches the changes in D23369, to use TLS_SLOT_TSAN only on Android (use the original variables on non-Android platforms).
Also adds named constants offsetof__msan_param_tls etc.
Now the bad news: it does actually TLS_SLOT_TSAN many times within a function. I've done some refactoring to cache the value, but it's broken.