[flang-commits] [flang] [flang] de-duplicate AbstractResult pass (PR #88867)

via flang-commits flang-commits at lists.llvm.org
Wed Apr 17 02:11:56 PDT 2024


================
@@ -304,9 +330,7 @@ inline void createDebugPasses(
 inline void createDefaultFIRCodeGenPassPipeline(
     mlir::PassManager &pm, MLIRToLLVMPassPipelineConfig config) {
   fir::addBoxedProcedurePass(pm);
-  pm.addNestedPass<mlir::func::FuncOp>(
-      fir::createAbstractResultOnFuncOptPass());
-  pm.addNestedPass<fir::GlobalOp>(fir::createAbstractResultOnGlobalOptPass());
+  addNestedPassToAllTopLevelOperations(pm, fir::createAbstractResultOptPass);
----------------
jeanPerier wrote:

Wouldn't using pm.nestAny(fir::createAbstractResultOptPass()) work?

It seems to me that the using both `addNestedPass<OP>` and `canScheduleOn` to restrict what this pass is being run on is a bit redundant (and probably less optimal it it means that the ModuleOp operations need to be walked three times to schedule the passes instead of scheduling it in a single pass, although I do not know the pass scheduling details enough to be sure how the module would be walked in both cases).

Although, maybe the reverse is better from a conceptual point of view: canScheduleOn could be removed from the pass definition. There is no conceptual aspects of the pass that restrict it from running on any operation that may contain FIR calls I think, so it would make sense to me that the pipeline is the only place describing which top level operations needs to be translated here.

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


More information about the flang-commits mailing list