Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / deep_stack2.cpp
blob16756867dd6d124c6b0a90832b5c2ddef444a79d
1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
4 volatile long X;
5 volatile long Y;
6 volatile int N1 = 2 << 10;
7 volatile int N2 = 32 << 10;
8 void (*volatile F)();
9 void (*volatile G)();
11 static void foo() {
12 if (--N1)
13 return F();
14 while (--N2)
15 G();
18 static void bar() { Y++; }
20 void *Thread(void *p) {
21 F();
22 X = 43;
23 barrier_wait(&barrier);
24 return 0;
27 int main() {
28 barrier_init(&barrier, 2);
29 F = foo;
30 G = bar;
31 pthread_t t;
32 pthread_create(&t, 0, Thread, 0);
33 barrier_wait(&barrier);
34 X = 43;
35 pthread_join(t, 0);
38 // CHECK: WARNING: ThreadSanitizer: data race
39 // CHECK: Write
40 // CHECK: #0 main
41 // CHECK: Previous write
42 // CHECK: #0 Thread