[flang-commits] [flang] [flang] Add the MLIR pass pipelines for dumping (PR #183144)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Wed Feb 25 05:12:10 PST 2026


================
@@ -207,6 +214,23 @@ bool executeCompilerInvocation(CompilerInstance *flang) {
 
   // Honor -mmlir. This should happen AFTER plugins have been loaded!
   if (!flang->getFrontendOpts().mlirArgs.empty()) {
+    // Register MLIR and FIR passes so that --mlir-print-ir-before=<pass> works.
+    // This must happen BEFORE registerPassManagerCLOptions() because that
+    // function creates the PassNameCLParser which snapshots the pass registry
+    // during initialization.
+    mlir::registerCSEPass();
+    mlir::registerCanonicalizerPass();
+    mlir::registerInlinerPass();
+    mlir::registerSCFToControlFlowPass();
+    mlir::registerConvertMathToFuncs();
+    mlir::registerConvertComplexToStandardPass();
+    mlir::registerConvertMathToLLVMPass();
+    mlir::LLVM::registerLLVMAddComdats();
+    mlir::registerReconcileUnrealizedCastsPass();
+    fir::registerOptCodeGenPasses();
+    fir::registerOptTransformPasses();
+    hlfir::registerHLFIRPasses();
+    flangomp::registerFlangOpenMPPasses();
----------------
kiranchandramohan wrote:

Can we share this code with relevant code in https://github.com/llvm/llvm-project/blob/cec03ae147c691fb3a48a043053f0def9f4a5a9a/flang/tools/fir-opt/fir-opt.cpp#L39 ?

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


More information about the flang-commits mailing list