Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / race_on_barrier.c
blob66fd339eb95bdc9b58ba18bbf5dd0ac55f247d1c
1 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
3 // pthread barriers are not available on OS X
4 // UNSUPPORTED: darwin
6 #include "test.h"
8 pthread_barrier_t B;
9 int Global;
11 void *Thread1(void *x) {
12 pthread_barrier_init(&B, 0, 2);
13 barrier_wait(&barrier);
14 pthread_barrier_wait(&B);
15 return NULL;
18 void *Thread2(void *x) {
19 barrier_wait(&barrier);
20 pthread_barrier_wait(&B);
21 return NULL;
24 int main() {
25 barrier_init(&barrier, 2);
26 pthread_t t;
27 pthread_create(&t, NULL, Thread1, NULL);
28 Thread2(0);
29 pthread_join(t, NULL);
30 pthread_barrier_destroy(&B);
31 return 0;
34 // CHECK: WARNING: ThreadSanitizer: data race