Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / tls_race.cpp
blob5f5b6aae4f586f6c645dff7c28396abea3a059f0
1 // RUN: %clangxx_tsan %darwin_min_target_with_tls_support -O1 %s -o %t && \
2 // RUN: %deflake %run %t | \
3 // RUN: FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
4 #include "test.h"
6 void *Thread(void *a) {
7 barrier_wait(&barrier);
8 *(int*)a = 43;
9 return 0;
12 int main() {
13 barrier_init(&barrier, 2);
14 static __thread int Var = 42;
15 pthread_t t;
16 pthread_create(&t, 0, Thread, &Var);
17 Var = 43;
18 barrier_wait(&barrier);
19 pthread_join(t, 0);
22 // CHECK: WARNING: ThreadSanitizer: data race
23 // CHECK-Linux: Location is TLS of main thread.
24 // CHECK-FreeBSD: Location is TLS of main thread.
25 // CHECK-NetBSD: Location is TLS of main thread.
26 // CHECK-Darwin: Location is heap block of size 4