[PATCH] D18894: [sanitizer] [SystemZ] Enable TLS functionality.
Marcin KoĆcielnicki via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 8 02:53:36 PDT 2016
koriakin created this revision.
koriakin added reviewers: uweigand, samsonov, eugenis.
koriakin added a subscriber: llvm-commits.
koriakin set the repository for this revision to rL LLVM.
koriakin added a project: Sanitizers.
This enables TLS knowledge for s390 in sanitizers.
Repository:
rL LLVM
http://reviews.llvm.org/D18894
Files:
lib/sanitizer_common/sanitizer_linux_libcdep.cc
Index: lib/sanitizer_common/sanitizer_linux_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -187,7 +187,7 @@
#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
#if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
- || defined(__aarch64__) || defined(__powerpc64__)) \
+ || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__)) \
&& SANITIZER_LINUX && !SANITIZER_ANDROID
// sizeof(struct pthread) from glibc.
static atomic_uintptr_t kThreadDescriptorSize;
@@ -249,6 +249,9 @@
val = 1776; // from glibc.ppc64le 2.20-8.fc21
atomic_store(&kThreadDescriptorSize, val, memory_order_relaxed);
return val;
+#elif defined(__s390__)
+ val = FIRST_32_SECOND_64(1152, 1776); // valid for glibc 2.22
+ atomic_store(&kThreadDescriptorSize, val, memory_order_relaxed);
#endif
return 0;
}
@@ -307,6 +310,12 @@
uptr thread_pointer;
asm("addi %0,13,%1" : "=r"(thread_pointer) : "I"(-kTlsTcbOffset));
descr_addr = thread_pointer - TlsPreTcbSize();
+# elif defined(__s390x__)
+ asm("ear %0, %%a0\n"
+ "sllg %0, %0, 32\n"
+ "ear %0, %%a1\n" : "=r"(descr_addr) :);
+# elif defined(__s390__)
+ asm("ear %0, %%a0\n" : "=r"(descr_addr) :);
# else
# error "unsupported CPU arch"
# endif
@@ -337,7 +346,7 @@
#if !SANITIZER_GO
static void GetTls(uptr *addr, uptr *size) {
#if SANITIZER_LINUX && !SANITIZER_ANDROID
-# if defined(__x86_64__) || defined(__i386__)
+# if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
*addr = ThreadSelf();
*size = GetTlsSize();
*addr -= *size;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18894.53009.patch
Type: text/x-patch
Size: 1718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160408/3f81a068/attachment.bin>
More information about the llvm-commits
mailing list