1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
6 void __attribute__((noinline
)) foo1() {
10 void __attribute__((noinline
)) bar1() {
11 volatile int tmp
= 42;
17 void __attribute__((noinline
)) foo2() {
18 volatile int tmp
= Global
;
23 void __attribute__((noinline
)) bar2() {
24 volatile int tmp
= 42;
30 void *Thread1(void *x
) {
31 barrier_wait(&barrier
);
37 barrier_init(&barrier
, 2);
39 pthread_create(&t
, NULL
, Thread1
, NULL
);
41 barrier_wait(&barrier
);
42 pthread_join(t
, NULL
);
45 // CHECK: WARNING: ThreadSanitizer: data race
46 // CHECK-NEXT: Write of size 4 at {{.*}} by thread T1:
47 // CHECK-NEXT: #0 foo1{{.*}} {{.*}}simple_stack2.cpp:[[@LINE-40]]{{(:10)?}} ({{.*}})
48 // CHECK-NEXT: #1 bar1{{.*}} {{.*}}simple_stack2.cpp:[[@LINE-34]]{{(:3)?}} ({{.*}})
49 // CHECK-NEXT: #2 Thread1{{.*}} {{.*}}simple_stack2.cpp:[[@LINE-17]]{{(:3)?}} ({{.*}})
50 // CHECK: Previous read of size 4 at {{.*}} by main thread:
51 // CHECK-NEXT: #0 foo2{{.*}} {{.*}}simple_stack2.cpp:[[@LINE-33]]{{(:22)?}} ({{.*}})
52 // CHECK-NEXT: #1 bar2{{.*}} {{.*}}simple_stack2.cpp:[[@LINE-25]]{{(:3)?}} ({{.*}})
53 // CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack2.cpp:[[@LINE-13]]{{(:3)?}} ({{.*}})