Author: Aman Maurya
Date: 2026-09-15T23:27:07-07:00
New Revision: ab8a9f9127cc0fbccd24a1e44a4e2e73c616d65e

URL: 
https://github.com/llvm/llvm-project/commit/ab8a9f9127cc0fbccd24a1e44a4e2e73c616d65e
DIFF: 
https://github.com/llvm/llvm-project/commit/ab8a9f9127cc0fbccd24a1e44a4e2e73c616d65e.diff

LOG: [CIR][NFC] Restore LoadOp builders, LowerToLLVM, and CIRGenBuiltin fixes 
lost in #222481 (#223896)

Commit 35c6acb89abf (#222481) accidentally reverted parts of
cc5e9d63b4dc (#222822) in `CIROps.td`, `LowerToLLVM.cpp`, and
`CIRGenBuiltin.cpp`, which broke Linux CI with deprecation and template
instantiation errors.

This change restores those lost changes:
1. Re-adds `LoadOp` custom builders in `CIROps.td` so calls to
`cir::LoadOp::create(builder, loc, addr)` and
`cir::LoadOp::create(builder, loc, resultTy, addr)` do not resolve to
deprecated MLIR collective builders.
2. Restores `lowerConstrainableFPOp` in `LowerToLLVM.cpp` to pass
default properties and type range to `replaceOpWithNewOp`.
3. Restores `emitUnaryFPBuiltin` in `CIRGenBuiltin.cpp` to use
non-deprecated `Operation::create(cgf.getBuilder(), arg.getLoc(), arg)`.

Diagnosed by Antigravity, formatted with Gemini

Added: 
    

Modified: 
    clang/include/clang/CIR/Dialect/IR/CIROps.td
    clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
    clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 64de9ecccb58c..c5a836a0c2f03 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -844,6 +844,21 @@ def CIR_LoadOp : CIR_Op<"load", [
     $addr `:` qualified(type($addr)) `,` type($result) attr-dict
   }];
 
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$addr), [{
+      build($_builder, $_state, addr, /*isDeref=*/false,
+            /*is_volatile=*/false, /*is_nontemporal=*/false,
+            /*alignment=*/mlir::IntegerAttr{}, cir::SyncScopeKindAttr{},
+            cir::MemOrderAttr{}, /*invariant=*/false);
+    }]>,
+    OpBuilder<(ins "mlir::Type":$result, "mlir::Value":$addr), [{
+      build($_builder, $_state, result, addr, /*isDeref=*/false,
+            /*is_volatile=*/false, /*is_nontemporal=*/false,
+            /*alignment=*/mlir::IntegerAttr{}, cir::SyncScopeKindAttr{},
+            cir::MemOrderAttr{}, /*invariant=*/false);
+    }]>
+  ];
+
   // FIXME: add verifier.
 }
 

diff  --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index c5c69e3d4067c..e2fe3adefd4af 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -567,8 +567,7 @@ static RValue 
emitUnaryMaybeConstrainedFPBuiltin(CIRGenFunction &cgf,
 template <class Operation>
 static RValue emitUnaryFPBuiltin(CIRGenFunction &cgf, const CallExpr &e) {
   mlir::Value arg = cgf.emitScalarExpr(e.getArg(0));
-  auto call =
-      Operation::create(cgf.getBuilder(), arg.getLoc(), arg.getType(), arg);
+  auto call = Operation::create(cgf.getBuilder(), arg.getLoc(), arg);
   return RValue::get(call->getResult(0));
 }
 

diff  --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp 
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 5eecf4d6c716b..39f7bb13caf08 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -571,7 +571,9 @@ mlir::LogicalResult lowerConstrainableFPOp(
     return op->emitError("expected LLVM result type for floating-point op");
 
   if (!fenv) {
-    rewriter.replaceOpWithNewOp<LLVMOp>(op, llvmResTy, operands);
+    rewriter.replaceOpWithNewOp<LLVMOp>(
+        op, mlir::TypeRange{llvmResTy}, operands,
+        cir::getDefaultProperties<LLVMOp>(op->getContext()));
     return mlir::success();
   }
 


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

Reply via email to