Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / ignore_malloc.cpp
blob6f293e3daa5ffcd37b30693f871e635c1ba234f1
1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include "test.h"
4 int *g;
6 void *Thread(void *a) {
7 int *p = 0;
8 while ((p = __atomic_load_n(&g, __ATOMIC_RELAXED)) == 0)
9 usleep(100); // spin-wait
10 *p = 42;
11 return 0;
14 int main() {
15 pthread_t t;
16 pthread_create(&t, 0, Thread, 0);
17 AnnotateIgnoreWritesBegin(__FILE__, __LINE__);
18 int *p = new int(0);
19 AnnotateIgnoreWritesEnd(__FILE__, __LINE__);
20 __atomic_store_n(&g, p, __ATOMIC_RELAXED);
21 pthread_join(t, 0);
22 delete p;
23 fprintf(stderr, "OK\n");
24 return 0;
27 // CHECK-NOT: WARNING: ThreadSanitizer: data race
28 // CHECK: OK