[PATCH] D14873: [tsan] Modify the tls_race.cc and tls_race2.cc tests to pass on OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 20 07:07:30 PST 2015


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, samsonov, kcc, glider.
kubabrecka added subscribers: llvm-commits, zaks.anna, ismailp.

On OS X, __thread variables are lazily heap-allocated (with malloc).  Therefore, they're recognized as heap blocks (which is what they are) and not as TLS variables in TSan reports.  Figuring out if a heap block is a TLS or not is difficult (in malloc interceptor we could analyze the caller and then mark the object), so let's instead modify the tests so that we expect the report to say "Location is heap block" instead of "Location is TLS".

http://reviews.llvm.org/D14873

Files:
  test/tsan/tls_race.cc
  test/tsan/tls_race2.cc

Index: test/tsan/tls_race2.cc
===================================================================
--- test/tsan/tls_race2.cc
+++ test/tsan/tls_race2.cc
@@ -1,4 +1,4 @@
-// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
 #include "test.h"
 
 void *Thread2(void *a) {
@@ -25,5 +25,6 @@
 }
 
 // CHECK: WARNING: ThreadSanitizer: data race
-// CHECK:   Location is TLS of thread T1.
-
+// CHECK-Linux:   Location is TLS of main thread.
+// CHECK-FreeBSD:   Location is TLS of main thread.
+// CHECK-Darwin:   Location is heap block of size 4
Index: test/tsan/tls_race.cc
===================================================================
--- test/tsan/tls_race.cc
+++ test/tsan/tls_race.cc
@@ -1,4 +1,4 @@
-// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
 #include "test.h"
 
 void *Thread(void *a) {
@@ -18,4 +18,6 @@
 }
 
 // CHECK: WARNING: ThreadSanitizer: data race
-// CHECK:   Location is TLS of main thread.
+// CHECK-Linux:   Location is TLS of main thread.
+// CHECK-FreeBSD:   Location is TLS of main thread.
+// CHECK-Darwin:   Location is heap block of size 4


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14873.40780.patch
Type: text/x-patch
Size: 1346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151120/e59676ef/attachment.bin>


More information about the llvm-commits mailing list