<div dir="ltr">Adding the XFAIL comments to race_on_mutex.cc broke the test by disturbing the line numbers. I updated them in r<span style="color:rgb(0,0,0)">255076. </span></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 8, 2015 at 1:54 PM, Bill Schmidt via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: wschmidt<br>
Date: Tue Dec  8 15:54:39 2015<br>
New Revision: 255057<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=255057&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=255057&view=rev</a><br>
Log:<br>
[PPC64, TSAN] LLVM basic enablement of thread sanitizer for PPC64 (BE and LE)<br>
<br>
This patch is by Simone Atzeni with portions by Adhemerval Zanella.<br>
<br>
This contains the LLVM patches to enable the thread sanitizer for<br>
PPC64, both big- and little-endian.  Two different virtual memory<br>
sizes are supported:  Old kernels use a 44-bit address space, while<br>
newer kernels require a 46-bit address space.<br>
<br>
There are two companion patches that will be added shortly.  There is<br>
a Clang patch to actually turn on the use of the thread sanitizer for<br>
PPC64.  There is also a patch that I wrote to provide interceptor<br>
support for setjmp/longjmp on PPC64.<br>
<br>
Patch discussion at <a href="http://reviews.llvm.org/D12841" rel="noreferrer" target="_blank">reviews.llvm.org/D12841</a>.<br>
<br>
<br>
Modified:<br>
    compiler-rt/trunk/cmake/config-ix.cmake<br>
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc<br>
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h<br>
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc<br>
    compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc<br>
    compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h<br>
    compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc<br>
    compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cc<br>
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h<br>
    compiler-rt/trunk/test/tsan/CMakeLists.txt<br>
    compiler-rt/trunk/test/tsan/cond_cancel.c<br>
    compiler-rt/trunk/test/tsan/java_race_pc.cc<br>
    compiler-rt/trunk/test/tsan/map32bit.cc<br>
    compiler-rt/trunk/test/tsan/mmap_large.cc<br>
    compiler-rt/trunk/test/tsan/race_on_mutex.c<br>
    compiler-rt/trunk/test/tsan/signal_errno.cc<br>
    compiler-rt/trunk/test/tsan/signal_longjmp.cc<br>
    compiler-rt/trunk/test/tsan/test.h<br>
<br>
Modified: compiler-rt/trunk/cmake/config-ix.cmake<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/cmake/config-ix.cmake (original)<br>
+++ compiler-rt/trunk/cmake/config-ix.cmake Tue Dec  8 15:54:39 2015<br>
@@ -278,7 +278,7 @@ set(ALL_LSAN_SUPPORTED_ARCH ${X86_64} ${<br>
 set(ALL_MSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})<br>
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC64}<br>
     ${MIPS32} ${MIPS64})<br>
-set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})<br>
+set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64})<br>
 set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}<br>
     ${MIPS32} ${MIPS64} ${PPC64})<br>
 set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64})<br>
<br>
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)<br>
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Tue Dec  8 15:54:39 2015<br>
@@ -89,7 +89,8 @@ const int FUTEX_WAKE = 1;<br>
 // Are we using 32-bit or 64-bit Linux syscalls?<br>
 // x32 (which defines __x86_64__) has SANITIZER_WORDSIZE == 32<br>
 // but it still needs to use 64-bit syscalls.<br>
-#if SANITIZER_LINUX && (defined(__x86_64__) || SANITIZER_WORDSIZE == 64)<br>
+#if SANITIZER_LINUX && (defined(__x86_64__) || defined(__powerpc64__) || \<br>
+    SANITIZER_WORDSIZE == 64)<br>
 # define SANITIZER_LINUX_USES_64BIT_SYSCALLS 1<br>
 #else<br>
 # define SANITIZER_LINUX_USES_64BIT_SYSCALLS 0<br>
@@ -983,6 +984,88 @@ uptr internal_clone(int (*fn)(void *), v<br>
                        : "x30", "memory");<br>
   return res;<br>
 }<br>
+#elif defined(__powerpc64__)<br>
+uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,<br>
+                   int *parent_tidptr, void *newtls, int *child_tidptr) {<br>
+  long long res;<br>
+/* Stack frame offsets.  */<br>
+#if _CALL_ELF != 2<br>
+#define FRAME_MIN_SIZE         112<br>
+#define FRAME_TOC_SAVE         40<br>
+#else<br>
+#define FRAME_MIN_SIZE         32<br>
+#define FRAME_TOC_SAVE         24<br>
+#endif<br>
+  if (!fn || !child_stack)<br>
+    return -EINVAL;<br>
+  CHECK_EQ(0, (uptr)child_stack % 16);<br>
+  child_stack = (char *)child_stack - 2 * sizeof(unsigned long long);<br>
+  ((unsigned long long *)child_stack)[0] = (uptr)fn;<br>
+  ((unsigned long long *)child_stack)[1] = (uptr)arg;<br>
+<br>
+  register int (*__fn)(void *) __asm__("r3") = fn;<br>
+  register void *__cstack      __asm__("r4") = child_stack;<br>
+  register int __flags         __asm__("r5") = flags;<br>
+  register void * __arg        __asm__("r6") = arg;<br>
+  register int * __ptidptr     __asm__("r7") = parent_tidptr;<br>
+  register void * __newtls     __asm__("r8") = newtls;<br>
+  register int * __ctidptr     __asm__("r9") = child_tidptr;<br>
+<br>
+ __asm__ __volatile__(<br>
+           /* fn, arg, child_stack are saved acrVoss the syscall */<br>
+           "mr 28, %5\n\t"<br>
+           "mr 29, %6\n\t"<br>
+           "mr 27, %8\n\t"<br>
+<br>
+           /* syscall<br>
+             r3 == flags<br>
+             r4 == child_stack<br>
+             r5 == parent_tidptr<br>
+             r6 == newtls<br>
+             r7 == child_tidptr */<br>
+           "mr 3, %7\n\t"<br>
+           "mr 5, %9\n\t"<br>
+           "mr 6, %10\n\t"<br>
+           "mr 7, %11\n\t"<br>
+           "li 0, %3\n\t"<br>
+           "sc\n\t"<br>
+<br>
+           /* Test if syscall was successful */<br>
+           "cmpdi  cr1, 3, 0\n\t"<br>
+           "crandc cr1*4+eq, cr1*4+eq, cr0*4+so\n\t"<br>
+           "bne-   cr1, 1f\n\t"<br>
+<br>
+           /* Do the function call */<br>
+           "std   2, %13(1)\n\t"<br>
+#if _CALL_ELF != 2<br>
+           "ld    0, 0(28)\n\t"<br>
+           "ld    2, 8(28)\n\t"<br>
+           "mtctr 0\n\t"<br>
+#else<br>
+           "mr    12, 28\n\t"<br>
+           "mtctr 12\n\t"<br>
+#endif<br>
+           "mr    3, 27\n\t"<br>
+           "bctrl\n\t"<br>
+           "ld    2, %13(1)\n\t"<br>
+<br>
+           /* Call _exit(r3) */<br>
+           "li 0, %4\n\t"<br>
+           "sc\n\t"<br>
+<br>
+           /* Return to parent */<br>
+           "1:\n\t"<br>
+           "mr %0, 3\n\t"<br>
+             : "=r" (res)<br>
+             : "0" (-1), "i" (EINVAL),<br>
+               "i" (__NR_clone), "i" (__NR_exit),<br>
+               "r" (__fn), "r" (__cstack), "r" (__flags),<br>
+               "r" (__arg), "r" (__ptidptr), "r" (__newtls),<br>
+               "r" (__ctidptr), "i" (FRAME_MIN_SIZE), "i" (FRAME_TOC_SAVE)<br>
+             : "cr0", "cr1", "memory", "ctr",<br>
+               "r0", "r29", "r27", "r28");<br>
+  return res;<br>
+}<br>
 #endif  // defined(__x86_64__) && SANITIZER_LINUX<br>
<br>
 #if SANITIZER_ANDROID<br>
<br>
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h (original)<br>
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h Tue Dec  8 15:54:39 2015<br>
@@ -44,7 +44,8 @@ uptr internal_prctl(int option, uptr arg<br>
 // internal_sigaction instead.<br>
 int internal_sigaction_norestorer(int signum, const void *act, void *oldact);<br>
 void internal_sigdelset(__sanitizer_sigset_t *set, int signum);<br>
-#if defined(__x86_64__) || defined(__mips__) || defined(__aarch64__)<br>
+#if defined(__x86_64__) || defined(__mips__) || defined(__aarch64__) \<br>
+  || defined(__powerpc64__)<br>
 uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,<br>
                     int *parent_tidptr, void *newtls, int *child_tidptr);<br>
 #endif<br>
<br>
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc (original)<br>
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc Tue Dec  8 15:54:39 2015<br>
@@ -15,7 +15,7 @@<br>
 #include "sanitizer_platform.h"<br>
<br>
 #if SANITIZER_LINUX && (defined(__x86_64__) || defined(__mips__) || \<br>
-                        defined(__aarch64__))<br>
+                        defined(__aarch64__) || defined(__powerpc64__))<br>
<br>
 #include "sanitizer_stoptheworld.h"<br>
<br>
@@ -511,5 +511,5 @@ uptr SuspendedThreadsList::RegisterCount<br>
 }<br>
 } // namespace __sanitizer<br>
<br>
-#endif // SANITIZER_LINUX && (defined(__x86_64__) || defined(__mips__)<br>
-       // || defined(__aarch64__)<br>
+#endif  // SANITIZER_LINUX && (defined(__x86_64__) || defined(__mips__)<br>
+        // || defined(__aarch64__) || defined(__powerpc64__)<br>
<br>
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)<br>
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Tue Dec  8 15:54:39 2015<br>
@@ -79,9 +79,11 @@ struct ucontext_t {<br>
 };<br>
 #endif<br>
<br>
-#if defined(__x86_64__) || defined(__mips__)<br>
+#if defined(__x86_64__) || defined(__mips__) \<br>
+  || (defined(__powerpc64__) && defined(__BIG_ENDIAN__))<br>
 #define PTHREAD_ABI_BASE  "GLIBC_2.3.2"<br>
-#elif defined(__aarch64__)<br>
+#elif defined(__aarch64__) || (defined(__powerpc64__) \<br>
+  && defined(__LITTLE_ENDIAN__))<br>
 #define PTHREAD_ABI_BASE  "GLIBC_2.17"<br>
 #endif<br>
<br>
<br>
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h (original)<br>
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h Tue Dec  8 15:54:39 2015<br>
@@ -161,6 +161,79 @@ struct Mapping42 {<br>
<br>
 // Indicates the runtime will define the memory regions at runtime.<br>
 #define TSAN_RUNTIME_VMA 1<br>
+#elif defined(__powerpc64__)<br>
+// PPC64 supports multiple VMA which leads to multiple address transformation<br>
+// functions.  To support these multiple VMAS transformations and mappings TSAN<br>
+// runtime for PPC64 uses an external memory read (vmaSize) to select which<br>
+// mapping to use.  Although slower, it make a same instrumented binary run on<br>
+// multiple kernels.<br>
+<br>
+/*<br>
+C/C++ on linux/powerpc64 (44-bit VMA)<br>
+0000 0000 0100 - 0001 0000 0000: main binary<br>
+0001 0000 0000 - 0001 0000 0000: -<br>
+0001 0000 0000 - 0b00 0000 0000: shadow<br>
+0b00 0000 0000 - 0b00 0000 0000: -<br>
+0b00 0000 0000 - 0d00 0000 0000: metainfo (memory blocks and sync objects)<br>
+0d00 0000 0000 - 0d00 0000 0000: -<br>
+0d00 0000 0000 - 0f00 0000 0000: traces<br>
+0f00 0000 0000 - 0f00 0000 0000: -<br>
+0f00 0000 0000 - 0f50 0000 0000: heap<br>
+0f50 0000 0000 - 0f60 0000 0000: -<br>
+0f60 0000 0000 - 1000 0000 0000: modules and main thread stack<br>
+*/<br>
+struct Mapping44 {<br>
+  static const uptr kMetaShadowBeg = 0x0b0000000000ull;<br>
+  static const uptr kMetaShadowEnd = 0x0d0000000000ull;<br>
+  static const uptr kTraceMemBeg   = 0x0d0000000000ull;<br>
+  static const uptr kTraceMemEnd   = 0x0f0000000000ull;<br>
+  static const uptr kShadowBeg     = 0x000100000000ull;<br>
+  static const uptr kShadowEnd     = 0x0b0000000000ull;<br>
+  static const uptr kLoAppMemBeg   = 0x000000000100ull;<br>
+  static const uptr kLoAppMemEnd   = 0x000100000000ull;<br>
+  static const uptr kHeapMemBeg    = 0x0f0000000000ull;<br>
+  static const uptr kHeapMemEnd    = 0x0f5000000000ull;<br>
+  static const uptr kHiAppMemBeg   = 0x0f6000000000ull;<br>
+  static const uptr kHiAppMemEnd   = 0x100000000000ull; // 44 bits<br>
+  static const uptr kAppMemMsk     = 0x0f0000000000ull;<br>
+  static const uptr kAppMemXor     = 0x002100000000ull;<br>
+  static const uptr kVdsoBeg       = 0x3c0000000000000ull;<br>
+};<br>
+<br>
+/*<br>
+C/C++ on linux/powerpc64 (46-bit VMA)<br>
+0000 0000 1000 - 0100 0000 0000: main binary<br>
+0100 0000 0000 - 0200 0000 0000: -<br>
+0100 0000 0000 - 1000 0000 0000: shadow<br>
+1000 0000 0000 - 1000 0000 0000: -<br>
+1000 0000 0000 - 2000 0000 0000: metainfo (memory blocks and sync objects)<br>
+2000 0000 0000 - 2000 0000 0000: -<br>
+2000 0000 0000 - 2200 0000 0000: traces<br>
+2200 0000 0000 - 3d00 0000 0000: -<br>
+3d00 0000 0000 - 3e00 0000 0000: heap<br>
+3e00 0000 0000 - 3e80 0000 0000: -<br>
+3e80 0000 0000 - 4000 0000 0000: modules and main thread stack<br>
+*/<br>
+struct Mapping46 {<br>
+  static const uptr kMetaShadowBeg = 0x100000000000ull;<br>
+  static const uptr kMetaShadowEnd = 0x200000000000ull;<br>
+  static const uptr kTraceMemBeg   = 0x200000000000ull;<br>
+  static const uptr kTraceMemEnd   = 0x220000000000ull;<br>
+  static const uptr kShadowBeg     = 0x010000000000ull;<br>
+  static const uptr kShadowEnd     = 0x100000000000ull;<br>
+  static const uptr kHeapMemBeg    = 0x3d0000000000ull;<br>
+  static const uptr kHeapMemEnd    = 0x3e0000000000ull;<br>
+  static const uptr kLoAppMemBeg   = 0x000000001000ull;<br>
+  static const uptr kLoAppMemEnd   = 0x010000000000ull;<br>
+  static const uptr kHiAppMemBeg   = 0x3e8000000000ull;<br>
+  static const uptr kHiAppMemEnd   = 0x400000000000ull; // 46 bits<br>
+  static const uptr kAppMemMsk     = 0x3c0000000000ull;<br>
+  static const uptr kAppMemXor     = 0x020000000000ull;<br>
+  static const uptr kVdsoBeg       = 0x7800000000000000ull;<br>
+};<br>
+<br>
+// Indicates the runtime will define the memory regions at runtime.<br>
+#define TSAN_RUNTIME_VMA 1<br>
 #endif<br>
<br>
 #elif defined(SANITIZER_GO) && !SANITIZER_WINDOWS<br>
@@ -274,6 +347,12 @@ uptr MappingArchImpl(void) {<br>
   else<br>
     return MappingImpl<Mapping42, Type>();<br>
   DCHECK(0);<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize == 44)<br>
+    return MappingImpl<Mapping44, Type>();<br>
+  else<br>
+    return MappingImpl<Mapping46, Type>();<br>
+  DCHECK(0);<br>
 #else<br>
   return MappingImpl<Mapping, Type>();<br>
 #endif<br>
@@ -399,6 +478,12 @@ bool IsAppMem(uptr mem) {<br>
   else<br>
     return IsAppMemImpl<Mapping42>(mem);<br>
   DCHECK(0);<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize == 44)<br>
+    return IsAppMemImpl<Mapping44>(mem);<br>
+  else<br>
+    return IsAppMemImpl<Mapping46>(mem);<br>
+  DCHECK(0);<br>
 #else<br>
   return IsAppMemImpl<Mapping>(mem);<br>
 #endif<br>
@@ -418,6 +503,12 @@ bool IsShadowMem(uptr mem) {<br>
   else<br>
     return IsShadowMemImpl<Mapping42>(mem);<br>
   DCHECK(0);<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize == 44)<br>
+    return IsShadowMemImpl<Mapping44>(mem);<br>
+  else<br>
+    return IsShadowMemImpl<Mapping46>(mem);<br>
+  DCHECK(0);<br>
 #else<br>
   return IsShadowMemImpl<Mapping>(mem);<br>
 #endif<br>
@@ -437,6 +528,12 @@ bool IsMetaMem(uptr mem) {<br>
   else<br>
     return IsMetaMemImpl<Mapping42>(mem);<br>
   DCHECK(0);<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize == 44)<br>
+    return IsMetaMemImpl<Mapping44>(mem);<br>
+  else<br>
+    return IsMetaMemImpl<Mapping46>(mem);<br>
+  DCHECK(0);<br>
 #else<br>
   return IsMetaMemImpl<Mapping>(mem);<br>
 #endif<br>
@@ -462,6 +559,12 @@ uptr MemToShadow(uptr x) {<br>
   else<br>
     return MemToShadowImpl<Mapping42>(x);<br>
   DCHECK(0);<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize == 44)<br>
+    return MemToShadowImpl<Mapping44>(x);<br>
+  else<br>
+    return MemToShadowImpl<Mapping46>(x);<br>
+  DCHECK(0);<br>
 #else<br>
   return MemToShadowImpl<Mapping>(x);<br>
 #endif<br>
@@ -489,6 +592,12 @@ u32 *MemToMeta(uptr x) {<br>
   else<br>
     return MemToMetaImpl<Mapping42>(x);<br>
   DCHECK(0);<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize == 44)<br>
+    return MemToMetaImpl<Mapping44>(x);<br>
+  else<br>
+    return MemToMetaImpl<Mapping46>(x);<br>
+  DCHECK(0);<br>
 #else<br>
   return MemToMetaImpl<Mapping>(x);<br>
 #endif<br>
@@ -522,6 +631,12 @@ uptr ShadowToMem(uptr s) {<br>
   else<br>
     return ShadowToMemImpl<Mapping42>(s);<br>
   DCHECK(0);<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize == 44)<br>
+    return ShadowToMemImpl<Mapping44>(s);<br>
+  else<br>
+    return ShadowToMemImpl<Mapping46>(s);<br>
+  DCHECK(0);<br>
 #else<br>
   return ShadowToMemImpl<Mapping>(s);<br>
 #endif<br>
@@ -549,6 +664,12 @@ uptr GetThreadTrace(int tid) {<br>
   else<br>
     return GetThreadTraceImpl<Mapping42>(tid);<br>
   DCHECK(0);<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize == 44)<br>
+    return GetThreadTraceImpl<Mapping44>(tid);<br>
+  else<br>
+    return GetThreadTraceImpl<Mapping46>(tid);<br>
+  DCHECK(0);<br>
 #else<br>
   return GetThreadTraceImpl<Mapping>(tid);<br>
 #endif<br>
@@ -571,6 +692,12 @@ uptr GetThreadTraceHeader(int tid) {<br>
   else<br>
     return GetThreadTraceHeaderImpl<Mapping42>(tid);<br>
   DCHECK(0);<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize == 44)<br>
+    return GetThreadTraceHeaderImpl<Mapping44>(tid);<br>
+  else<br>
+    return GetThreadTraceHeaderImpl<Mapping46>(tid);<br>
+  DCHECK(0);<br>
 #else<br>
   return GetThreadTraceHeaderImpl<Mapping>(tid);<br>
 #endif<br>
<br>
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)<br>
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Tue Dec  8 15:54:39 2015<br>
@@ -244,11 +244,19 @@ void InitializePlatformEarly() {<br>
 #ifdef TSAN_RUNTIME_VMA<br>
   vmaSize =<br>
     (MostSignificantSetBitIndex(GET_CURRENT_FRAME()) + 1);<br>
+#if defined(__aarch64__)<br>
   if (vmaSize != 39 && vmaSize != 42) {<br>
     Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");<br>
     Printf("FATAL: Found %d - Supported 39 and 42\n", vmaSize);<br>
     Die();<br>
   }<br>
+#elif defined(__powerpc64__)<br>
+  if (vmaSize != 44 && vmaSize != 46) {<br>
+    Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");<br>
+    Printf("FATAL: Found %d - Supported 42 and 46\n", vmaSize);<br>
+    Die();<br>
+  }<br>
+#endif<br>
 #endif<br>
 }<br>
<br>
<br>
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cc (original)<br>
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cc Tue Dec  8 15:54:39 2015<br>
@@ -58,6 +58,18 @@ void InitializeShadowMemory() {<br>
   } else {<br>
     DCHECK(0);<br>
   }<br>
+#elif defined(__powerpc64__)<br>
+  uptr kMadviseRangeBeg = 0;<br>
+  uptr kMadviseRangeSize = 0;<br>
+  if (vmaSize == 44) {<br>
+    kMadviseRangeBeg  = 0x0f60000000ull;<br>
+    kMadviseRangeSize = 0x0010000000ull;<br>
+  } else if (vmaSize == 46) {<br>
+    kMadviseRangeBeg  = 0x3f0000000000ull;<br>
+    kMadviseRangeSize = 0x010000000000ull;<br>
+  } else {<br>
+    DCHECK(0);<br>
+  }<br>
 #endif<br>
   NoHugePagesInRegion(MemToShadow(kMadviseRangeBeg),<br>
                       kMadviseRangeSize * kShadowMultiplier);<br>
<br>
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)<br>
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Tue Dec  8 15:54:39 2015<br>
@@ -54,7 +54,7 @@ namespace __tsan {<br>
<br>
 #ifndef SANITIZER_GO<br>
 struct MapUnmapCallback;<br>
-#if defined(__mips64) || defined(__aarch64__)<br>
+#if defined(__mips64) || defined(__aarch64__) || defined(__powerpc__)<br>
 static const uptr kAllocatorSpace = 0;<br>
 static const uptr kAllocatorSize = SANITIZER_MMAP_RANGE_SIZE;<br>
 static const uptr kAllocatorRegionSizeLog = 20;<br>
<br>
Modified: compiler-rt/trunk/test/tsan/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/CMakeLists.txt?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/CMakeLists.txt?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/CMakeLists.txt (original)<br>
+++ compiler-rt/trunk/test/tsan/CMakeLists.txt Tue Dec  8 15:54:39 2015<br>
@@ -1,5 +1,5 @@<br>
 set(TSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})<br>
-if(NOT ${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "mips")<br>
+if(${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "x86_64")<br>
   list(APPEND TSAN_TEST_DEPS GotsanRuntimeCheck)<br>
 endif()<br>
 if(NOT COMPILER_RT_STANDALONE_BUILD)<br>
<br>
Modified: compiler-rt/trunk/test/tsan/cond_cancel.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/cond_cancel.c?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/cond_cancel.c?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/cond_cancel.c (original)<br>
+++ compiler-rt/trunk/test/tsan/cond_cancel.c Tue Dec  8 15:54:39 2015<br>
@@ -1,6 +1,14 @@<br>
 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s<br>
 // CHECK-NOT: WARNING<br>
 // CHECK: OK<br>
+// This test is failing on powerpc64 (VMA=44). After calling pthread_cancel,<br>
+// the Thread-specific data destructors are not called, so the destructor<br>
+// "thread_finalize" (defined in tsan_interceptors.cc) can not set the status<br>
+// of the thread to "ThreadStatusFinished" failing a check in "SetJoined"<br>
+// (defined in sanitizer_thread_registry.cc). It might seem a bug on glibc,<br>
+// however the same version GLIBC-2.17 will not make fail the test on<br>
+// powerpc64 (VMA=46)<br>
+// XFAIL: powerpc64<br>
<br>
 #include "test.h"<br>
<br>
<br>
Modified: compiler-rt/trunk/test/tsan/java_race_pc.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/java_race_pc.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/java_race_pc.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/java_race_pc.cc (original)<br>
+++ compiler-rt/trunk/test/tsan/java_race_pc.cc Tue Dec  8 15:54:39 2015<br>
@@ -1,4 +1,8 @@<br>
 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s<br>
+// This test fails on powerpc64 on both VMA (44 and 46).<br>
+// The Tsan report is returning wrong information about<br>
+// the location of the race.<br>
+// XFAIL: powerpc64<br>
 #include "java.h"<br>
<br>
 void foobar() {<br>
<br>
Modified: compiler-rt/trunk/test/tsan/map32bit.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/map32bit.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/map32bit.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/map32bit.cc (original)<br>
+++ compiler-rt/trunk/test/tsan/map32bit.cc Tue Dec  8 15:54:39 2015<br>
@@ -10,6 +10,7 @@<br>
 // MAP_32BIT flag for mmap is supported only for x86_64.<br>
 // XFAIL: mips64<br>
 // XFAIL: aarch64<br>
+// XFAIL: powerpc64<br>
<br>
 // MAP_32BIT doesn't exist on OS X.<br>
 // UNSUPPORTED: darwin<br>
<br>
Modified: compiler-rt/trunk/test/tsan/mmap_large.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/mmap_large.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/mmap_large.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/mmap_large.cc (original)<br>
+++ compiler-rt/trunk/test/tsan/mmap_large.cc Tue Dec  8 15:54:39 2015<br>
@@ -16,6 +16,8 @@ int main() {<br>
   const size_t kLog2Size = 39;<br>
 #elif defined(__mips64) || defined(__aarch64__)<br>
   const size_t kLog2Size = 32;<br>
+#elif defined(__powerpc64__)<br>
+  const size_t kLog2Size = 39;<br>
 #endif<br>
   const uintptr_t kLocation = 0x40ULL << kLog2Size;<br>
   void *p = mmap(<br>
<br>
Modified: compiler-rt/trunk/test/tsan/race_on_mutex.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/race_on_mutex.c?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/race_on_mutex.c?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/race_on_mutex.c (original)<br>
+++ compiler-rt/trunk/test/tsan/race_on_mutex.c Tue Dec  8 15:54:39 2015<br>
@@ -1,4 +1,7 @@<br>
 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s<br>
+// This test fails on powerpc64 (VMA=46).<br>
+// The size of the write reported by Tsan for T1 is 8 instead of 1.<br>
+// XFAIL: powerpc64<br>
 #include "test.h"<br>
<br>
 pthread_mutex_t Mtx;<br>
<br>
Modified: compiler-rt/trunk/test/tsan/signal_errno.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/signal_errno.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/signal_errno.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/signal_errno.cc (original)<br>
+++ compiler-rt/trunk/test/tsan/signal_errno.cc Tue Dec  8 15:54:39 2015<br>
@@ -1,4 +1,8 @@<br>
 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s<br>
+// This test fails on powerpc64 (VMA=44), it does not appear to be<br>
+// a functional problem, but the Tsan report is missing some info.<br>
+// XFAIL: powerpc64<br>
+<br>
 #include "test.h"<br>
 #include <signal.h><br>
 #include <sys/types.h><br>
<br>
Modified: compiler-rt/trunk/test/tsan/signal_longjmp.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/signal_longjmp.cc?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/signal_longjmp.cc?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/signal_longjmp.cc (original)<br>
+++ compiler-rt/trunk/test/tsan/signal_longjmp.cc Tue Dec  8 15:54:39 2015<br>
@@ -5,6 +5,10 @@<br>
<br>
 // Longjmp assembly has not been implemented for mips64 yet<br>
 // XFAIL: mips64<br>
+// This test fails on powerpc64 (VMA=44), a segmentation fault<br>
+// error happens at the second assignment<br>
+// "((volatile int *volatile)mem)[1] = 1".<br>
+// XFAIL: powerpc64<br>
<br>
 #include <setjmp.h><br>
 #include <signal.h><br>
<br>
Modified: compiler-rt/trunk/test/tsan/test.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/test.h?rev=255057&r1=255056&r2=255057&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/test.h?rev=255057&r1=255056&r2=255057&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/test.h (original)<br>
+++ compiler-rt/trunk/test/tsan/test.h Tue Dec  8 15:54:39 2015<br>
@@ -43,7 +43,7 @@ void print_address(const char *str, int<br>
   va_start(ap, n);<br>
   while (n--) {<br>
     void *p = va_arg(ap, void *);<br>
-#if defined(__x86_64__) || defined(__aarch64__)<br>
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)<br>
     // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not<br>
     // match to the format used in the diagnotic message.<br>
     fprintf(stderr, "0x%012lx ", (unsigned long) p);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>