[mlir] Support passing ostream as argument for the create function.
authorOkwan Kwon <okwan@google.com>
Thu, 9 Jun 2022 22:11:36 +0000 (15:11 -0700)
committerOkwan Kwon <okwan@google.com>
Thu, 9 Jun 2022 23:34:22 +0000 (16:34 -0700)
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

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

index f6e1feeaf05ef175927cdb3bde2e5ad0abc664a8..49a6442a79d90b9e7b87fd43e69df59601ca3714 100644 (file)
@@ -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.
index 4f77d5f99356803b0b664357e6b7729d64e71828..8adc4117f9542169c4834e1161eddf6e8411d823 100644 (file)
@@ -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);
 }