Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / mutex_lock_destroyed.cpp
blobb727b92b31aca14155f328deb47c52af995a60d2
1 // RUN: %clangxx_tsan %s -o %t
2 // RUN: %deflake %run %t | FileCheck %s
3 // RUN: %deflake %run %t 1 | FileCheck %s
5 // The pthread_mutex_lock interceptor assumes incompatible internals w/ NetBSD
6 // XFAIL: target={{.*netbsd.*}}
8 #include <pthread.h>
9 #include <stdio.h>
10 #include <stdlib.h>
12 int main(int argc, char *argv[]) {
13 pthread_mutex_t *m = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
14 pthread_mutex_init(m, 0);
15 pthread_mutex_lock(m);
16 pthread_mutex_unlock(m);
17 pthread_mutex_destroy(m);
19 if (argc > 1 && argv[1][0] == '1')
20 free(m);
22 pthread_mutex_lock(m);
23 // CHECK: WARNING: ThreadSanitizer: use of an invalid mutex (e.g. uninitialized or destroyed)
24 // CHECK: #0 pthread_mutex_lock
25 // CHECK: #1 main {{.*}}mutex_lock_destroyed.cpp:[[@LINE-3]]
27 return 0;