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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jul 31 03:11:18 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Author: Hideto Ueno (uenoku)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/101315.diff


3 Files Affected:

- (modified) mlir/lib/Transforms/OpStats.cpp (+1) 
- (modified) mlir/lib/Transforms/PrintIR.cpp (+1) 
- (modified) mlir/lib/Transforms/ViewOpGraph.cpp (+1) 


``````````diff
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`.

``````````

</details>


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


More information about the Mlir-commits mailing list