Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / print_full_thread_history.cpp
blobff341f6bfae8078925be8bbd3d034cf86b158346
1 // RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=print_full_thread_history=true %deflake %run %t 2>&1 | FileCheck %s
3 #include "test.h"
5 int Global;
7 void *Thread2(void *x) {
8 barrier_wait(&barrier);
9 Global++;
10 return NULL;
13 void *Thread3(void *x) {
14 Global--;
15 barrier_wait(&barrier);
16 return NULL;
19 void *Thread1(void *x) {
20 pthread_t t[2];
21 pthread_create(&t[0], NULL, Thread2, NULL);
22 pthread_create(&t[1], NULL, Thread3, NULL);
23 pthread_join(t[0], NULL);
24 pthread_join(t[1], NULL);
25 return NULL;
28 int main() {
29 barrier_init(&barrier, 2);
30 pthread_t t;
31 pthread_create(&t, NULL, Thread1, NULL);
32 pthread_join(t, NULL);
33 return 0;
36 // CHECK: WARNING: ThreadSanitizer: data race
37 // CHECK: Thread T2 {{.*}} created by thread T1 at
38 // CHECK: Thread T3 {{.*}} created by thread T1 at:
39 // CHECK: Thread T1 {{.*}} created by main thread at:
40 // CHECK: SUMMARY: ThreadSanitizer: data race{{.*}}