[Mlir-commits] [mlir] [mlir][Transforms] Preserve all analysis in print passes (PR #101315)

Hideto Ueno llvmlistbot at llvm.org
Wed Jul 31 03:10:45 PDT 2024


https://github.com/uenoku created https://github.com/llvm/llvm-project/pull/101315

PrintIRPass, PrintOpStatsPass and PrintOpGraphPass don't mutate IR so preserve all analysis to save computation resource a bit.

>From bb9d5a6846eb4434251bfef4a55b0d87a24f9181 Mon Sep 17 00:00:00 2001
From: Hideto Ueno <uenoku.tokotoko at gmail.com>
Date: Wed, 31 Jul 2024 03:06:25 -0700
Subject: [PATCH] [mlir][Transforms] Preserve all analysis in print passes

PrintIRPass, PrintOpStatsPass and PrintOpGraphPass don't mutate IR so
preserve all analysis.
---
 mlir/lib/Transforms/OpStats.cpp     | 1 +
 mlir/lib/Transforms/PrintIR.cpp     | 1 +
 mlir/lib/Transforms/ViewOpGraph.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/mlir/lib/Transforms/OpStats.cpp b/mlir/lib/Transforms/OpStats.cpp
index 6a71e1f02edc9..6746ed52396af 100644
--- a/mlir/lib/Transforms/OpStats.cpp
+++ b/mlir/lib/Transforms/OpStats.cpp
@@ -55,6 +55,7 @@ void PrintOpStatsPass::runOnOperation() {
     printSummaryInJSON();
   } else
     printSummary();
+  markAllAnalysesPreserved();
 }
 
 void PrintOpStatsPass::printSummary() {
diff --git a/mlir/lib/Transforms/PrintIR.cpp b/mlir/lib/Transforms/PrintIR.cpp
index cc42c7e2f1db0..3c55f920dfd61 100644
--- a/mlir/lib/Transforms/PrintIR.cpp
+++ b/mlir/lib/Transforms/PrintIR.cpp
@@ -25,6 +25,7 @@ struct PrintIRPass : public impl::PrintIRPassBase<PrintIRPass> {
       llvm::dbgs() << " " << this->label;
     llvm::dbgs() << " //----- //\n";
     getOperation()->dump();
+    markAllAnalysesPreserved();
   }
 };
 
diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp
index b3c0a06c96fea..82e9863ab40bf 100644
--- a/mlir/lib/Transforms/ViewOpGraph.cpp
+++ b/mlir/lib/Transforms/ViewOpGraph.cpp
@@ -93,6 +93,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
       processOperation(getOperation());
       emitAllEdgeStmts();
     });
+    markAllAnalysesPreserved();
   }
 
   /// Create a CFG graph for a region. Used in `Region::viewGraph`.



More information about the Mlir-commits mailing list