================
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o 
%t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o 
%t-cir.ll
+// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
+
+extern "C" {
+
+// CIR-LABEL: @test_sync_val_compare_and_swap(
+// CIR: cir.atomic.cmpxchg success(seq_cst) failure(seq_cst) syncscope(system) 
%{{[0-9]+}}, %{{[0-9]+}}, %{{[0-9]+}} : (!cir.ptr<!s32i>, !s32i, !s32i) -> 
(!s32i, !cir.bool)
+// CIR: cir.return
+int test_sync_val_compare_and_swap(int *p, int old, int newval) {
+  return __sync_val_compare_and_swap(p, old, newval);
+}
+
+// CIR-LABEL: @test_sync_bool_compare_and_swap(
+// CIR: cir.atomic.cmpxchg success(seq_cst) failure(seq_cst) syncscope(system) 
%{{[0-9]+}}, %{{[0-9]+}}, %{{[0-9]+}} : (!cir.ptr<!s32i>, !s32i, !s32i) -> 
(!s32i, !cir.bool)
+// CIR: cir.return
+int test_sync_bool_compare_and_swap(int *p, int old, int newval) {
+  return __sync_bool_compare_and_swap(p, old, newval);
+}
+
+// CIR-LABEL: @test_sync_swap(
+// CIR: cir.atomic.xchg seq_cst syncscope(system) %{{[0-9]+}}, %{{[0-9]+}} : 
(!cir.ptr<!s32i>, !s32i) -> !s32i
+// CIR: cir.return
+int test_sync_swap(int *p, int val) {
+  return __sync_swap(p, val);
+}
+
+// CIR-LABEL: @test_sync_lock_test_and_set(
+// CIR: cir.atomic.xchg acquire syncscope(system) %{{[0-9]+}}, %{{[0-9]+}} : 
(!cir.ptr<!s32i>, !s32i) -> !s32i
----------------
Lancern wrote:

Is `acquire` right? The OGCG would emit `seq_cst` instead.

https://github.com/llvm/llvm-project/pull/214606
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to