Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / libdispatch / semaphore-norace.c
blob36e03dce80a94f69491ed8cf5c9f2ad6a19726fd
1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include <dispatch/dispatch.h>
6 #include <stdio.h>
8 long global;
10 int main() {
11 fprintf(stderr, "Hello world.");
13 global = 42;
15 dispatch_semaphore_t sem = dispatch_semaphore_create(0);
16 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
18 global = 43;
19 dispatch_semaphore_signal(sem);
20 });
22 dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
23 global = 44;
25 fprintf(stderr, "Done.");
26 return 0;
29 // CHECK: Hello world.
30 // CHECK: Done.