[Mlir-commits] [mlir] 5ccb9df - [mlir] Support passing ostream as argument for the create function.

Okwan Kwon llvmlistbot at llvm.org
Thu Jun 9 16:36:30 PDT 2022


Author: Okwan Kwon
Date: 2022-06-09T16:34:22-07:00
New Revision: 5ccb9df3ba3b246fd38990bc97aca47844cf3aa4

URL: https://github.com/llvm/llvm-project/commit/5ccb9df3ba3b246fd38990bc97aca47844cf3aa4
DIFF: https://github.com/llvm/llvm-project/commit/5ccb9df3ba3b246fd38990bc97aca47844cf3aa4.diff

LOG: [mlir] Support passing ostream as argument for the create function.

The constructor already supports passing an ostream as argument,
so let's make the create function support it too.

Differential Revision: https://reviews.llvm.org/D127449

Added: 
    

Modified: 
    mlir/include/mlir/Transforms/Passes.h
    mlir/lib/Transforms/OpStats.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h
index f6e1feeaf05ef..49a6442a79d90 100644
--- a/mlir/include/mlir/Transforms/Passes.h
+++ b/mlir/include/mlir/Transforms/Passes.h
@@ -60,7 +60,7 @@ std::unique_ptr<Pass> createStripDebugInfoPass();
 
 /// Creates a pass which prints the list of ops and the number of occurrences in
 /// the module.
-std::unique_ptr<Pass> createPrintOpStatsPass();
+std::unique_ptr<Pass> createPrintOpStatsPass(raw_ostream &os = llvm::errs());
 
 /// Creates a pass which inlines calls and callable operations as defined by
 /// the CallGraph.

diff  --git a/mlir/lib/Transforms/OpStats.cpp b/mlir/lib/Transforms/OpStats.cpp
index 4f77d5f993568..8adc4117f9542 100644
--- a/mlir/lib/Transforms/OpStats.cpp
+++ b/mlir/lib/Transforms/OpStats.cpp
@@ -19,7 +19,7 @@ using namespace mlir;
 
 namespace {
 struct PrintOpStatsPass : public PrintOpStatsBase<PrintOpStatsPass> {
-  explicit PrintOpStatsPass(raw_ostream &os = llvm::errs()) : os(os) {}
+  explicit PrintOpStatsPass(raw_ostream &os) : os(os) {}
 
   // Prints the resultant operation statistics post iterating over the module.
   void runOnOperation() override;
@@ -80,6 +80,6 @@ void PrintOpStatsPass::printSummary() {
   }
 }
 
-std::unique_ptr<Pass> mlir::createPrintOpStatsPass() {
-  return std::make_unique<PrintOpStatsPass>();
+std::unique_ptr<Pass> mlir::createPrintOpStatsPass(raw_ostream &os) {
+  return std::make_unique<PrintOpStatsPass>(os);
 }


        


More information about the Mlir-commits mailing list