[clang] [CIR] Add codegen for atomic fence builtin with non-const memory order (PR #172455)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 16 04:55:14 PST 2025
================
@@ -179,3 +179,427 @@ void loadWithSignalFence(DataPtr d) {
// OGCG: %[[DATA_TEMP_LOAD]] = load ptr, ptr %[[DATA_TEMP]], align 8
// OGCG: ret void
}
+
+void const_atomic_thread_fence() {
+ __atomic_thread_fence(__ATOMIC_RELAXED);
+ __atomic_thread_fence(__ATOMIC_CONSUME);
+ __atomic_thread_fence(__ATOMIC_ACQUIRE);
+ __atomic_thread_fence(__ATOMIC_RELEASE);
+ __atomic_thread_fence(__ATOMIC_ACQ_REL);
+ __atomic_thread_fence(__ATOMIC_SEQ_CST);
+ // CIR-LABEL: const_atomic_thread_fence
+ // CIR: cir.atomic.fence syncscope(system) acquire
+ // CIR: cir.atomic.fence syncscope(system) acquire
+ // CIR: cir.atomic.fence syncscope(system) release
+ // CIR: cir.atomic.fence syncscope(system) acq_rel
+ // CIR: cir.atomic.fence syncscope(system) seq_cst
----------------
Lancern wrote:
We could add a NOT test for the relaxed case:
```c
// CIR-NOT: cir.atomic.fence syncscope(system) relaxed
```
https://github.com/llvm/llvm-project/pull/172455
More information about the cfe-commits
mailing list