[clang] [CIR] Lower complex mul and div before callconv lowering (PR #216498)

Adam Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 11:50:03 PDT 2026


================
@@ -525,9 +544,13 @@ cir::GlobalOp LoweringPreparePass::getOrCreateRuntimeVariable(
   return g;
 }
 
-cir::FuncOp LoweringPreparePass::buildRuntimeFunction(
-    mlir::OpBuilder &builder, llvm::StringRef name, mlir::Location loc,
-    cir::FuncType type, cir::GlobalLinkageKind linkage) {
+/// Declare `name` in `mlirModule` if it is not already declared there, and
+/// return the declaration.  Free-standing so that ComplexLoweringPass can
+/// reach it without a LoweringPreparePass instance.
+static cir::FuncOp buildRuntimeFunction(
+    mlir::OpBuilder &builder, mlir::ModuleOp mlirModule, llvm::StringRef name,
----------------
adams381 wrote:

It moved to `CIRTransformUtils`, which already holds the shared transform helpers.

While looking into this I discovered there is already a second copy. `EHABILowering.cpp` has `getOrCreateRuntimeFuncDecl`, which performs the same action.  However, its signature is a little different.  I can remove that copy and have it use this one, but it is in EH code and I'm not sure that change belongs here.  I think I should file a separate followup PR to clean that up.

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


More information about the cfe-commits mailing list