Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / sleep_sync.cpp
blob7d6787edfe7405709d67cbebf5faf25cc6b085c7
1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
4 int X = 0;
6 __attribute__((noinline)) void MySleep() {
7 sleep(1); // the sleep that must appear in the report
10 void *Thread(void *p) {
11 barrier_wait(&barrier);
12 MySleep(); // Assume the main thread has done the write.
13 X = 42;
14 return 0;
17 int main() {
18 barrier_init(&barrier, 2);
19 pthread_t t;
20 pthread_create(&t, 0, Thread, 0);
21 X = 43;
22 barrier_wait(&barrier);
23 pthread_join(t, 0);
24 return 0;
27 // CHECK: WARNING: ThreadSanitizer: data race
28 // ...
29 // CHECK: As if synchronized via sleep:
30 // CHECK-NEXT: #0 sleep
31 // CHECK-NEXT: #1 MySleep
32 // CHECK-NEXT: #2 Thread