-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cilksan] Add hook for LLVM intrinsic for x86 pause instruction. Fix …
…issue OpenCilk/infrastructure#21.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %clang_cilksan -fopencilk -O0 %s -o %t | ||
// RUN: %run %t 2>&1 | FileCheck %s | ||
|
||
#include <cilk/cilk.h> | ||
#include <stdio.h> | ||
|
||
_Atomic int x = 0; | ||
|
||
void foo(void) { | ||
while (!x) { | ||
#ifdef __SSE__ | ||
__builtin_ia32_pause(); | ||
#endif | ||
#ifdef __aarch64__ | ||
__builtin_arm_yield(); | ||
#endif | ||
} | ||
++x; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
cilk_spawn { ++x; } | ||
foo(); | ||
cilk_sync; | ||
printf("x=%d\n", x); | ||
return 0; | ||
} | ||
|
||
// CHECK: Running Cilksan race detector | ||
// CHECK-NEXT: x=2 | ||
// CHECK: Cilksan detected 0 distinct races. | ||
// CHECK-NEXT: Cilksan suppressed 0 duplicate race reports. |