Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / custom_mutex0.cpp
blobda83048d9c5e6991fed4486e14bb8e00904b8ce2
1 // RUN: %clangxx_tsan -O1 --std=c++11 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include "custom_mutex.h"
4 // Test that custom annotations provide normal mutex synchronization
5 // (no race reports for properly protected critical sections).
7 Mutex mu(true, 0);
8 long data;
10 void *thr(void *arg) {
11 barrier_wait(&barrier);
12 mu.Lock();
13 data++;
14 mu.Unlock();
15 return 0;
18 int main() {
19 barrier_init(&barrier, 2);
20 pthread_t th;
21 pthread_create(&th, 0, thr, 0);
22 barrier_wait(&barrier);
23 mu.Lock();
24 data++;
25 mu.Unlock();
26 pthread_join(th, 0);
27 fprintf(stderr, "DONE\n");
28 return 0;
31 // CHECK: DONE