Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / ignore_sync.cpp
blob7a129fb57d6029632a96e618573ae7c80b57c82d
1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
4 int Global;
5 pthread_mutex_t Mutex = PTHREAD_MUTEX_INITIALIZER;
7 void *Thread(void *x) {
8 AnnotateIgnoreSyncBegin(0, 0);
9 pthread_mutex_lock(&Mutex);
10 Global++;
11 pthread_mutex_unlock(&Mutex);
12 AnnotateIgnoreSyncEnd(0, 0);
13 return 0;
16 int main() {
17 pthread_t t;
18 pthread_create(&t, 0, Thread, 0);
19 pthread_mutex_lock(&Mutex);
20 Global++;
21 pthread_mutex_unlock(&Mutex);
22 pthread_join(t, 0);
25 // CHECK: WARNING: ThreadSanitizer: data race