Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / race_stress.cpp
blob38acefce6e4626c719ad8042cfb4f5b8b0cfd1f3
1 // RUN: %clangxx_tsan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
2 #include "test.h"
4 const int kThreads = 16;
5 const int kIters = 1000;
7 volatile int X = 0;
9 void *thr(void *arg) {
10 for (int i = 0; i < kIters; i++)
11 X++;
12 return 0;
15 int main() {
16 pthread_t th[kThreads];
17 for (int i = 0; i < kThreads; i++)
18 pthread_create(&th[i], 0, thr, 0);
19 for (int i = 0; i < kThreads; i++)
20 pthread_join(th[i], 0);
21 fprintf(stderr, "DONE\n");
24 // CHECK: ThreadSanitizer: data race
25 // CHECK: DONE