Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / bench_local_mutex.cpp
blob15f83bc8b282f4c4b21226fad914024e9a4afbf4
1 // RUN: %clangxx_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s
4 // bench.h needs pthread barriers which are not available on OS X
5 // UNSUPPORTED: darwin
7 #include "bench.h"
9 pthread_mutex_t *mtx;
10 const int kStride = 16;
12 void thread(int tid) {
13 for (int i = 0; i < bench_niter; i++) {
14 pthread_mutex_lock(&mtx[tid * kStride]);
15 pthread_mutex_unlock(&mtx[tid * kStride]);
19 void bench() {
20 mtx = (pthread_mutex_t*)malloc(bench_nthread * kStride * sizeof(*mtx));
21 for (int i = 0; i < bench_nthread; i++) {
22 pthread_mutex_init(&mtx[i * kStride], 0);
23 pthread_mutex_lock(&mtx[i * kStride]);
24 pthread_mutex_unlock(&mtx[i * kStride]);
26 start_thread_group(bench_nthread, thread);
29 // CHECK: DONE