Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / ignore_free.cpp
blob51037b14d946674d5e3808e827d3dbcfe80822ac
1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include "test.h"
4 void *Thread(void *p) {
5 *(int*)p = 42;
6 barrier_wait(&barrier);
7 return 0;
10 int main() {
11 barrier_init(&barrier, 2);
12 int *p = new int(0);
13 pthread_t t;
14 pthread_create(&t, 0, Thread, p);
15 barrier_wait(&barrier);
16 AnnotateIgnoreReadsBegin(__FILE__, __LINE__);
17 AnnotateIgnoreWritesBegin(__FILE__, __LINE__);
18 free(p);
19 AnnotateIgnoreReadsEnd(__FILE__, __LINE__);
20 AnnotateIgnoreWritesEnd(__FILE__, __LINE__);
21 pthread_join(t, 0);
22 fprintf(stderr, "OK\n");
23 return 0;
26 // CHECK-NOT: WARNING: ThreadSanitizer: data race
27 // CHECK: OK