================
@@ -1174,26 +1177,48 @@ static RValue emitLibCallForAtomicExpr(CIRGenFunction 
&cgf, AtomicExpr *e,
   case AtomicExpr::AO__atomic_compare_exchange_n:
   case AtomicExpr::AO__c11_atomic_compare_exchange_weak:
   case AtomicExpr::AO__c11_atomic_compare_exchange_strong:
-  case AtomicExpr::AO__hip_atomic_compare_exchange_weak:
-  case AtomicExpr::AO__hip_atomic_compare_exchange_strong:
+  case AtomicExpr::AO__scoped_atomic_compare_exchange:
+  case AtomicExpr::AO__scoped_atomic_compare_exchange_n: {
+    calleeName = "__atomic_compare_exchange";
+    retTy = cgf.getContext().BoolTy;
+    hasRetTy = true;
+    order = cgf.emitScalarExpr(e->getOrderFail());
+    args.add(RValue::get(castToGenericAddrSpace(val1.emitRawPointer(),
+                                                e->getVal1()->getType())),
+             cgf.getContext().VoidPtrTy);
+    args.add(RValue::get(castToGenericAddrSpace(val2.emitRawPointer(),
+                                                e->getVal2()->getType())),
+             cgf.getContext().VoidPtrTy);
+    break;
----------------
andykaylor wrote:

This doesn't look quite right. Classic codegen adds the order argument here 
before changing the order value:
```
Args.add(RValue::get(Order), getContext().IntTy);
Order = OrderFail;
```
Here's an example that this PR gets wrong:
```
struct Big { long x[3]; };
bool test(struct Big *p, struct Big *expected, struct Big *desired) {
  return __atomic_compare_exchange(
      p, expected, desired, false,
      __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE);
}
```

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

Reply via email to