Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / benign_race.cpp
blob53e820d9507facb36f3b0b764d0f1c01be421afa
1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include "test.h"
4 int Global;
5 int WTFGlobal;
7 void *Thread(void *x) {
8 Global = 42;
9 WTFGlobal = 142;
10 barrier_wait(&barrier);
11 return 0;
14 int main() {
15 barrier_init(&barrier, 2);
16 ANNOTATE_BENIGN_RACE(Global);
17 WTF_ANNOTATE_BENIGN_RACE(WTFGlobal);
18 pthread_t t;
19 pthread_create(&t, 0, Thread, 0);
20 barrier_wait(&barrier);
21 Global = 43;
22 WTFGlobal = 143;
23 pthread_join(t, 0);
24 fprintf(stderr, "OK\n");
27 // CHECK-NOT: WARNING: ThreadSanitizer: data race