-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR][CIRGen] Support for builtin __atomic_thread_fence
Resolves #1274 Implements atomic thread fence synchronization primitive corresponding to `atomic.thread_fence` CIR.
- Loading branch information
1 parent
d329c96
commit 6425312
Showing
5 changed files
with
134 additions
and
1 deletion.
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
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
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,40 @@ | ||
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-cir %s -o %t.cir | ||
// RUN: FileCheck --input-file=%t.cir %s | ||
// UN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll | ||
// UN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s | ||
|
||
|
||
struct Data { | ||
int value; | ||
void *ptr; | ||
}; | ||
|
||
typedef struct Data *DataPtr; | ||
|
||
void applyThreadFence() { | ||
__atomic_thread_fence(5); | ||
} | ||
|
||
void applySignalFence() { | ||
__atomic_signal_fence(5); | ||
} | ||
|
||
void modifyWithThreadFence(DataPtr d) { | ||
__atomic_thread_fence(5); | ||
d->value = 42; | ||
} | ||
|
||
void modifyWithSignalFence(DataPtr d) { | ||
__atomic_signal_fence(5); | ||
d->value = 24; | ||
} | ||
|
||
void loadWithThreadFence(DataPtr d) { | ||
__atomic_thread_fence(5); | ||
__atomic_load_n(&d->ptr, 5); | ||
} | ||
|
||
void loadWithSignalFence(DataPtr d) { | ||
__atomic_signal_fence(5); | ||
__atomic_load_n(&d->ptr, 5); | ||
} |