Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / Darwin / osspinlock-norace.cpp
blob5de02c225f0b3915776dd1a4cd7fc14b7cda4277
1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdint.h>
4 #include <stdio.h>
6 typedef int32_t OSSpinLock;
7 extern "C" void OSSpinLockLock(OSSpinLock *);
8 extern "C" void OSSpinLockUnlock(OSSpinLock *);
10 int Global;
11 OSSpinLock lock;
13 void *Thread(void *x) {
14 OSSpinLockLock(&lock);
15 Global++;
16 OSSpinLockUnlock(&lock);
17 return NULL;
20 int main() {
21 fprintf(stderr, "Hello world.\n");
23 pthread_t t[2];
24 pthread_create(&t[0], NULL, Thread, NULL);
25 pthread_create(&t[1], NULL, Thread, NULL);
26 pthread_join(t[0], NULL);
27 pthread_join(t[1], NULL);
29 fprintf(stderr, "Done.\n");
32 // CHECK: Hello world.
33 // CHECK: Done.
34 // CHECK-NOT: WARNING: ThreadSanitizer