Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / race_on_mutex2.c
blob6ee5438f566ee2f4e13d91011c364e066ddb9be5
1 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
4 void *Thread(void *x) {
5 pthread_mutex_lock((pthread_mutex_t*)x);
6 pthread_mutex_unlock((pthread_mutex_t*)x);
7 barrier_wait(&barrier);
8 return 0;
11 int main() {
12 barrier_init(&barrier, 2);
13 pthread_mutex_t Mtx;
14 pthread_mutex_init(&Mtx, 0);
15 pthread_t t;
16 pthread_create(&t, 0, Thread, &Mtx);
17 barrier_wait(&barrier);
18 pthread_mutex_destroy(&Mtx);
19 pthread_join(t, 0);
20 return 0;
23 // CHECK: WARNING: ThreadSanitizer: data race