[compiler-rt] 4438201 - [compiler-rt] TlsBaseAddr value for darwin arm64

David CARLIER via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 8 14:27:31 PST 2021


Author: David CARLIER
Date: 2021-11-08T22:26:32Z
New Revision: 443820179a849eac6ddb5cbf0ba5cc7bbc42e2d2

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

LOG: [compiler-rt] TlsBaseAddr value for darwin arm64

getting the tls base address. unlike linux arm64, the tpidr_el0 returns always 0 (aka unused)
thus using tpidrro_el0 instead clearing up the cpu id encoded in the lower bits.

Reviewed-By: yln

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

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 36a9d5098042..b67203d4c10e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -543,6 +543,9 @@ uptr TlsBaseAddr() {
   asm("movq %%gs:0,%0" : "=r"(segbase));
 #elif defined(__i386__)
   asm("movl %%gs:0,%0" : "=r"(segbase));
+#elif defined(__aarch64__)
+  asm("mrs %x0, tpidrro_el0" : "=r"(segbase));
+  segbase &= 0x07ul;  // clearing lower bits, cpu id stored there
 #endif
   return segbase;
 }


        


More information about the llvm-commits mailing list