Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / atexit4.cpp
blob6126e8c1622e14c3d7f4f736ac1fb3c5e5fef6c1
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 *static_cast<int *>(x) = 2;
7 return nullptr;
10 static void race() {
11 int data = 0;
12 pthread_t t;
13 pthread_create(&t, nullptr, thread, &data);
14 data = 1;
15 barrier_wait(&barrier);
16 pthread_join(t, nullptr);
19 struct X {
20 __attribute__((noinline))
21 X() { atexit(race); }
22 } x;
24 int main() {
25 barrier_init(&barrier, 2);
26 fprintf(stderr, "DONE\n");
29 // CHECK: DONE
30 // CHECK: WARNING: ThreadSanitizer: data race
31 // CHECK: Write of size 4
32 // CHECK: #0 thread
33 // CHECK: Previous write of size 4
34 // CHECK: #0 race
35 // CHECK: #1 at_exit_callback_installed_at
36 // CHECK: #2 X