Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / thread_leak5.c
blobacdbd1d38a9b8f12b68803dcef9fc790655288b6
1 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
4 void *Thread(void *x) {
5 barrier_wait(&barrier);
6 return 0;
9 int main() {
10 volatile int N = 5; // prevent loop unrolling
11 barrier_init(&barrier, N + 1);
12 for (int i = 0; i < N; i++) {
13 pthread_t t;
14 pthread_create(&t, 0, Thread, 0);
16 barrier_wait(&barrier);
17 sleep(1); // wait for the threads to finish and exit
18 return 0;
21 // CHECK: WARNING: ThreadSanitizer: thread leak
22 // CHECK: And 4 more similar thread leaks