Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / halt_on_error.cpp
blob5d481c3cbcd6a9a988713da622a14c22a54f5f07
1 // RUN: %clang_tsan -O1 %s -o %t && %env_tsan_opts=halt_on_error=1 %deflake %run %t | FileCheck %s
2 #include "test.h"
4 int X;
6 void *Thread(void *x) {
7 barrier_wait(&barrier);
8 X = 42;
9 return 0;
12 int main() {
13 barrier_init(&barrier, 2);
14 fprintf(stderr, "BEFORE\n");
15 pthread_t t;
16 pthread_create(&t, 0, Thread, 0);
17 X = 43;
18 barrier_wait(&barrier);
19 pthread_join(t, 0);
20 fprintf(stderr, "AFTER\n");
21 return 0;
24 // CHECK: BEFORE
25 // CHECK: WARNING: ThreadSanitizer: data race
26 // CHECK-NOT: AFTER