[clang] [CIR] Defer emitting function definitions (PR #142862)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 4 16:23:10 PDT 2025


================
@@ -1523,6 +1523,50 @@ cir::FuncOp CIRGenModule::getOrCreateCIRFunction(
   cir::FuncOp funcOp = createCIRFunction(
       invalidLoc ? theModule->getLoc() : getLoc(funcDecl->getSourceRange()),
       mangledName, mlir::cast<cir::FuncType>(funcType), funcDecl);
+
+  if (!dontDefer) {
----------------
andykaylor wrote:

There's an assertion below this in the incubator and classic codegen (which I might as well add now), but it's easily moved to the early return.

It seems to me that `dontDefer` is a somewhat misleading name. If it is true, it means that we aren't ready to move this from the `deferredDecls` list to the `declsToEmit` list yet. Nothing gets deferred here either way. It really should be something like `dontMoveToEmitList` which is really closer to `dontStopDeferring`. The current name dates back to OGCG. I think any renaming can wait for a future change. I just thought I'd mention it here.

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


More information about the cfe-commits mailing list