This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [tsan] Fix GetTls for aarch64
ClosedPublic

Authored by zatrazz on Aug 26 2015, 6:13 PM.

Details

Summary

This patch fix the function GetTls for aarch64, where it assumes it
follows the x86_64 way where the TLS initial address is at the end
of TLS. Instead aarch64 set the TLS address as the thread pointer.

Diff Detail

Event Timeline

zatrazz updated this revision to Diff 33291.Aug 26 2015, 6:13 PM
zatrazz retitled this revision from to [compiler-rt] [tsan] Fix GetTls for aarch64.
zatrazz updated this object.
zatrazz added reviewers: kcc, eugenis, pcc, dvyukov, rengolin.
zatrazz added a subscriber: llvm-commits.
dvyukov accepted this revision.Aug 27 2015, 12:49 AM
dvyukov edited edge metadata.

Not that I understand why this is correct, but if you need a rubber stamp...
LGTM

This revision is now accepted and ready to land.Aug 27 2015, 12:49 AM

To give you more context on GLIBC code for aarch64:

sysdeps/aarch64/nptl/tls.h:
49 /* The TP points to the start of the thread blocks. */
50 # define TLS_DTV_AT_TP 1
51 # define TLS_TCB_AT_TP 0

93 # define TLS_INIT_TP(tcbp) \
94 ({ asm volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); NULL; })

And on:

csu/libc-tls.c:

/* Initialize the thread pointer.  */

#if TLS_TCB_AT_TP

INSTALL_DTV ((char *) tlsblock + tcb_offset, _dl_static_dtv);

const char *lossage = TLS_INIT_TP ((char *) tlsblock + tcb_offset);

#elif TLS_DTV_AT_TP

INSTALL_DTV (tlsblock, _dl_static_dtv);
const char *lossage = TLS_INIT_TP (tlsblock);

So different than x86_64 (which defines TLS_TCB_AT_TP), aarch64 set the thread register pointers as the TLS allocated block.

zatrazz closed this revision.Aug 27 2015, 7:04 AM