[clang] [CIR] Upstream __sync_<OP>_and_fetch builtins (PR #168347)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 17 12:58:22 PST 2025


================
@@ -58,6 +59,107 @@ static RValue emitBuiltinBitOp(CIRGenFunction &cgf, const CallExpr *e,
   return RValue::get(result);
 }
 
+/// Emit the conversions required to turn the given value into an
+/// integer of the given size.
+static mlir::Value emitToInt(CIRGenFunction &cgf, mlir::Value v, QualType t,
+                             cir::IntType intType) {
+  v = cgf.emitToMemory(v, t);
+
+  if (isa<cir::PointerType>(v.getType()))
----------------
andykaylor wrote:

```suggestion
  if (mlir::isa<cir::PointerType>(v.getType()))
```
Making this explicit is a nice hint to readers of the code who aren't familiar with MLIR, letting them know that this can be subtly different (specifically, `llvm::isa<>` only works with pointers, whereas this is acting on an object that wraps a pointer).

https://github.com/llvm/llvm-project/pull/168347


More information about the cfe-commits mailing list