[PATCH] D33286: Don't require ThreadState to be contained within tls on all platforms

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 09:00:58 PDT 2017


fjricci created this revision.

The existing code ran CHECKs to assert that the thread state pointer
was stored in tls. However, the mac implementation of tsan
doesn't store the pointer in tls, so these checks fail once
tls darwin support is added. Move to soft if-condition checks instead.


https://reviews.llvm.org/D33286

Files:
  lib/tsan/rtl/tsan_rtl_thread.cc


Index: lib/tsan/rtl/tsan_rtl_thread.cc
===================================================================
--- lib/tsan/rtl/tsan_rtl_thread.cc
+++ lib/tsan/rtl/tsan_rtl_thread.cc
@@ -252,14 +252,13 @@
       // Check that the thr object is in tls;
       const uptr thr_beg = (uptr)thr;
       const uptr thr_end = (uptr)thr + sizeof(*thr);
-      CHECK_GE(thr_beg, tls_addr);
-      CHECK_LE(thr_beg, tls_addr + tls_size);
-      CHECK_GE(thr_end, tls_addr);
-      CHECK_LE(thr_end, tls_addr + tls_size);
-      // Since the thr object is huge, skip it.
-      MemoryRangeImitateWrite(thr, /*pc=*/ 2, tls_addr, thr_beg - tls_addr);
-      MemoryRangeImitateWrite(thr, /*pc=*/ 2,
-          thr_end, tls_addr + tls_size - thr_end);
+      if (thr_beg > tls_addr && thr_beg < tls_addr + tls_size &&
+          thr_end < tls_addr && thr_end < tls_addr + tls_size) {
+        // Since the thr object is huge, skip it.
+        MemoryRangeImitateWrite(thr, /*pc=*/2, tls_addr, thr_beg - tls_addr);
+        MemoryRangeImitateWrite(thr, /*pc=*/2, thr_end,
+                                tls_addr + tls_size - thr_end);
+      }
     }
   }
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33286.99313.patch
Type: text/x-patch
Size: 1146 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170517/3708c357/attachment.bin>


More information about the llvm-commits mailing list