Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / race_on_fputs.cpp
blob53042e3d36bcaa62d182aeebdb6759bb822c2774
1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
4 char s[] = "abracadabra";
6 void *Thread0(void *p) {
7 fputs(s, stdout);
8 barrier_wait(&barrier);
9 return 0;
12 void *Thread1(void *p) {
13 barrier_wait(&barrier);
14 s[3] = 'z';
15 return 0;
18 int main() {
19 barrier_init(&barrier, 2);
20 pthread_t th[2];
21 pthread_create(&th[0], 0, Thread0, 0);
22 pthread_create(&th[1], 0, Thread1, 0);
23 pthread_join(th[0], 0);
24 pthread_join(th[1], 0);
25 fprintf(stderr, "DONE");
28 // CHECK: WARNING: ThreadSanitizer: data race
29 // CHECK: DONE