[compiler-rt] r286670 - Tread TSan LLVM flags to driver: unit tests.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 11 15:17:49 PST 2016


Author: eugenis
Date: Fri Nov 11 17:17:49 2016
New Revision: 286670

URL: http://llvm.org/viewvc/llvm-project?rev=286670&view=rev
Log:
Tread TSan LLVM flags to driver: unit tests.

Summary: Unit tests for the new clang flags.

Reviewers: eugenis, dvyukov

Subscribers: kubabrecka, llvm-commits

Patch by Alex Shlyapnikov.

Differential Revision: https://reviews.llvm.org/D26462

Modified:
    compiler-rt/trunk/test/tsan/atomic_free.cc
    compiler-rt/trunk/test/tsan/global_race.cc
    compiler-rt/trunk/test/tsan/simple_stack.c

Modified: compiler-rt/trunk/test/tsan/atomic_free.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/atomic_free.cc?rev=286670&r1=286669&r2=286670&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/atomic_free.cc (original)
+++ compiler-rt/trunk/test/tsan/atomic_free.cc Fri Nov 11 17:17:49 2016
@@ -1,4 +1,13 @@
-// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t 2>&1 | FileCheck %s
+
+// Also check that atomics instrumentation can be configured by either driver or
+// legacy flags:
+
+// RUN: %clangxx_tsan -O1 %s -o %t -fno-sanitize-thread-atomics && not %deflake %run %t 2>&1 \
+// RUN:   | FileCheck --allow-empty --check-prefix=CHECK-NO-ATOMICS %s
+// RUN: %clangxx_tsan -O1 %s -o %t -mllvm -tsan-instrument-atomics=0 && not %deflake %run %t 2>&1 \
+// RUN:   | FileCheck --allow-empty --check-prefix=CHECK-NO-ATOMICS %s <%t.out
+
 #include "test.h"
 
 void *Thread(void *a) {
@@ -18,3 +27,5 @@ int main() {
 }
 
 // CHECK: WARNING: ThreadSanitizer: data race
+
+// CHECK-NO-ATOMICS-NOT: WARNING: ThreadSanitizer: data race

Modified: compiler-rt/trunk/test/tsan/global_race.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/global_race.cc?rev=286670&r1=286669&r2=286670&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/global_race.cc (original)
+++ compiler-rt/trunk/test/tsan/global_race.cc Fri Nov 11 17:17:49 2016
@@ -1,4 +1,14 @@
-// RUN: %clangxx_tsan -O1 %s -o %T/global_race.cc.exe && %deflake %run %T/global_race.cc.exe | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s -o %T/global_race.cc.exe && %deflake %run %T/global_race.cc.exe 2>&1 \
+// RUN:   | FileCheck %s
+
+// Also check that memory access instrumentation can be configured by either
+// driver or legacy flags:
+
+// RUN: %clangxx_tsan -O1 %s -o %T/global_race.cc.exe -fno-sanitize-thread-memory-access && not %deflake %run %T/global_race.cc.exe 2>&1 \
+// RUN:   | FileCheck --allow-empty --check-prefix=CHECK-MEMORY-ACCESS-OFF %s
+// RUN: %clangxx_tsan -O1 %s -o %T/global_race.cc.exe -mllvm -tsan-instrument-memory-accesses=0 && not %deflake %run %T/global_race.cc.exe 2>&1 \
+// RUN:   | FileCheck --allow-empty --check-prefix=CHECK-MEMORY-ACCESS-OFF %s
+
 #include "test.h"
 
 int GlobalData[10];
@@ -23,3 +33,4 @@ int main() {
 // CHECK: WARNING: ThreadSanitizer: data race
 // CHECK: Location is global 'GlobalData' {{(of size 40 )?}}at [[ADDR]] (global_race.cc.exe+0x{{[0-9,a-f]+}})
 
+// CHECK-MEMORY-ACCESS-OFF-NOT: WARNING: ThreadSanitizer: data race

Modified: compiler-rt/trunk/test/tsan/simple_stack.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/simple_stack.c?rev=286670&r1=286669&r2=286670&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/simple_stack.c (original)
+++ compiler-rt/trunk/test/tsan/simple_stack.c Fri Nov 11 17:17:49 2016
@@ -1,4 +1,3 @@
-// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
 #include "test.h"
 
 int Global;
@@ -47,20 +46,42 @@ int main() {
   return 0;
 }
 
+// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t 2>&1 | FileCheck %s
+
+// Also check that functions instrumentation can be configured by either driver
+// or legacy flags:
+
+// RUN: %clangxx_tsan -O1 %s -o %t -fno-sanitize-thread-func-entry-exit && %deflake %run %t 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FUNC-ENTRY-EXIT-OFF %s
+// RUN: %clangxx_tsan -O1 %s -o %t -mllvm -tsan-instrument-func-entry-exit=0 && %deflake %run %t 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FUNC-ENTRY-EXIT-OFF %s
+
 // CHECK:      WARNING: ThreadSanitizer: data race
 // CHECK-NEXT:   Write of size 4 at {{.*}} by thread T1:
-// CHECK-NEXT:     #0 foo1{{.*}} {{.*}}simple_stack.c:7{{(:10)?}} ({{.*}})
-// CHECK-NEXT:     #1 bar1{{.*}} {{.*}}simple_stack.c:12{{(:3)?}} ({{.*}})
-// CHECK-NEXT:     #2 Thread1{{.*}} {{.*}}simple_stack.c:26{{(:3)?}} ({{.*}})
+// CHECK-NEXT:     #0 foo1{{.*}} {{.*}}simple_stack.c:6{{(:10)?}} ({{.*}})
+// CHECK-NEXT:     #1 bar1{{.*}} {{.*}}simple_stack.c:11{{(:3)?}} ({{.*}})
+// CHECK-NEXT:     #2 Thread1{{.*}} {{.*}}simple_stack.c:25{{(:3)?}} ({{.*}})
 // CHECK:        Previous read of size 4 at {{.*}} by thread T2:
-// CHECK-NEXT:     #0 foo2{{.*}} {{.*}}simple_stack.c:16{{(:20)?}} ({{.*}})
-// CHECK-NEXT:     #1 bar2{{.*}} {{.*}}simple_stack.c:21{{(:3)?}} ({{.*}})
-// CHECK-NEXT:     #2 Thread2{{.*}} {{.*}}simple_stack.c:31{{(:3)?}} ({{.*}})
+// CHECK-NEXT:     #0 foo2{{.*}} {{.*}}simple_stack.c:15{{(:20)?}} ({{.*}})
+// CHECK-NEXT:     #1 bar2{{.*}} {{.*}}simple_stack.c:20{{(:3)?}} ({{.*}})
+// CHECK-NEXT:     #2 Thread2{{.*}} {{.*}}simple_stack.c:30{{(:3)?}} ({{.*}})
 // CHECK:        Thread T1 (tid={{.*}}, running) created by main thread at:
 // CHECK-NEXT:     #0 pthread_create {{.*}} ({{.*}})
-// CHECK-NEXT:     #1 StartThread{{.*}} {{.*}}simple_stack.c:37{{(:3)?}} ({{.*}})
-// CHECK-NEXT:     #2 main{{.*}} {{.*}}simple_stack.c:43{{(:3)?}} ({{.*}})
+// CHECK-NEXT:     #1 StartThread{{.*}} {{.*}}simple_stack.c:36{{(:3)?}} ({{.*}})
+// CHECK-NEXT:     #2 main{{.*}} {{.*}}simple_stack.c:42{{(:3)?}} ({{.*}})
 // CHECK:        Thread T2 ({{.*}}) created by main thread at:
 // CHECK-NEXT:     #0 pthread_create {{.*}} ({{.*}})
-// CHECK-NEXT:     #1 StartThread{{.*}} {{.*}}simple_stack.c:37{{(:3)?}} ({{.*}})
-// CHECK-NEXT:     #2 main{{.*}} {{.*}}simple_stack.c:44{{(:3)?}} ({{.*}})
+// CHECK-NEXT:     #1 StartThread{{.*}} {{.*}}simple_stack.c:36{{(:3)?}} ({{.*}})
+// CHECK-NEXT:     #2 main{{.*}} {{.*}}simple_stack.c:43{{(:3)?}} ({{.*}})
+
+// CHECK-FUNC-ENTRY-EXIT-OFF:      WARNING: ThreadSanitizer: data race
+// CHECK-FUNC-ENTRY-EXIT-OFF-NEXT:   Write of size 4 at {{.*}} by thread T1:
+// CHECK-FUNC-ENTRY-EXIT-OFF-NEXT:     #0 foo1{{.*}} {{.*}}simple_stack.c:6{{(:10)?}} ({{.*}})
+// CHECK-FUNC-ENTRY-EXIT-OFF:        Previous read of size 4 at {{.*}} by thread T2:
+// CHECK-FUNC-ENTRY-EXIT-OFF-NEXT:     #0 foo2{{.*}} {{.*}}simple_stack.c:15{{(:20)?}} ({{.*}})
+// CHECK-FUNC-ENTRY-EXIT-OFF:        Thread T1 (tid={{.*}}, running) created by main thread at:
+// CHECK-FUNC-ENTRY-EXIT-OFF-NEXT:     #0 pthread_create {{.*}} ({{.*}})
+// CHECK-FUNC-ENTRY-EXIT-OFF-NEXT:     #1 main{{.*}} {{.*}}simple_stack.c:42{{(:3)?}} ({{.*}})
+// CHECK-FUNC-ENTRY-EXIT-OFF:        Thread T2 ({{.*}}) created by main thread at:
+// CHECK-FUNC-ENTRY-EXIT-OFF-NEXT:     #0 pthread_create {{.*}} ({{.*}})
+// CHECK-FUNC-ENTRY-EXIT-OFF-NEXT:     #1 main{{.*}} {{.*}}simple_stack.c:43{{(:3)?}} ({{.*}})




More information about the llvm-commits mailing list