Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / fd_location.cpp
blob1861c89cba9b1d9c71c26e5bc71f020718651182
1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
4 int fds[2];
6 void *Thread1(void *x) {
7 write(fds[1], "a", 1);
8 barrier_wait(&barrier);
9 return NULL;
12 void *Thread2(void *x) {
13 barrier_wait(&barrier);
14 close(fds[0]);
15 close(fds[1]);
16 return NULL;
19 int main() {
20 barrier_init(&barrier, 2);
21 pipe(fds);
22 pthread_t t[2];
23 pthread_create(&t[0], NULL, Thread1, NULL);
24 pthread_create(&t[1], NULL, Thread2, NULL);
25 pthread_join(t[0], NULL);
26 pthread_join(t[1], NULL);
29 // CHECK: WARNING: ThreadSanitizer: data race
30 // CHECK: Location is file descriptor {{[0-9]+}} created by main thread at:
31 // CHECK: #0 pipe
32 // CHECK: #1 main