Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / tsan-vs-gvn.cpp
blobefd81ef502fd2760804177afc34c4d342dc54f89
1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 // RUN: %clangxx_tsan -O2 %s -o %t && %run %t 2>&1 | FileCheck %s
3 // RUN: %clangxx_tsan -O3 %s -o %t && %run %t 2>&1 | FileCheck %s
4 //
5 // Check that load widening is not tsan-hostile.
6 #include <pthread.h>
7 #include <stdio.h>
8 #include <string.h>
10 struct {
11 int i;
12 char c1, c2, c3, c4;
13 } S;
15 int G;
17 void *Thread1(void *x) {
18 G = S.c1 + S.c3;
19 return NULL;
22 void *Thread2(void *x) {
23 S.c2 = 1;
24 return NULL;
27 int main() {
28 pthread_t t[2];
29 memset(&S, 123, sizeof(S));
30 pthread_create(&t[0], NULL, Thread1, NULL);
31 pthread_create(&t[1], NULL, Thread2, NULL);
32 pthread_join(t[0], NULL);
33 pthread_join(t[1], NULL);
34 fprintf(stderr, "PASS\n");
37 // CHECK-NOT: WARNING: ThreadSanitizer: data race
38 // CHECK: PASS