Skip to content

Commit 4438201

Browse files
committed
[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
1 parent 2caf85a commit 4438201

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ uptr TlsBaseAddr() {
543543
asm("movq %%gs:0,%0" : "=r"(segbase));
544544
#elif defined(__i386__)
545545
asm("movl %%gs:0,%0" : "=r"(segbase));
546+
#elif defined(__aarch64__)
547+
asm("mrs %x0, tpidrro_el0" : "=r"(segbase));
548+
segbase &= 0x07ul; // clearing lower bits, cpu id stored there
546549
#endif
547550
return segbase;
548551
}

0 commit comments

Comments
 (0)