[compiler-rt] f3932ae - tsan: fix cur_thread alignment

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 28 07:49:48 PDT 2021


Author: Dmitry Vyukov
Date: 2021-09-28T16:49:44+02:00
New Revision: f3932ae1a078075e9e35f51ead3aaca05a9a23c7

URL: https://github.com/llvm/llvm-project/commit/f3932ae1a078075e9e35f51ead3aaca05a9a23c7
DIFF: https://github.com/llvm/llvm-project/commit/f3932ae1a078075e9e35f51ead3aaca05a9a23c7.diff

LOG: tsan: fix cur_thread alignment

Commit 354ded67b3 ("tsan: align ThreadState to cache line")
did an incomplete thing. It marked ThreadState as cache line
aligned, but the thread local ThreadState instance is declared
as an aligned char array with hard-coded 64-byte alignment.
On PowerPC cache line size is 128 bytes, so the hard-coded
64-byte alignment is not enough.
Use cache line alignment consistently.

Differential Revision: https://reviews.llvm.org/D110629

Added: 
    

Modified: 
    compiler-rt/lib/tsan/rtl/tsan_rtl.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
index d67928224545c..ea7ff56dd0c35 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -43,9 +43,10 @@ int (*on_finalize)(int);
 
 #if !SANITIZER_GO && !SANITIZER_MAC
 __attribute__((tls_model("initial-exec")))
-THREADLOCAL char cur_thread_placeholder[sizeof(ThreadState)] ALIGNED(64);
+THREADLOCAL char cur_thread_placeholder[sizeof(ThreadState)] ALIGNED(
+    SANITIZER_CACHE_LINE_SIZE);
 #endif
-static char ctx_placeholder[sizeof(Context)] ALIGNED(64);
+static char ctx_placeholder[sizeof(Context)] ALIGNED(SANITIZER_CACHE_LINE_SIZE);
 Context *ctx;
 
 // Can be overriden by a front-end.


        


More information about the llvm-commits mailing list