diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -118,7 +118,7 @@ /// Prints out the pass in the textual representation of pipelines. If this is /// an adaptor pass, print with the op_name(sub_pass,...) format. - void printAsTextualPipeline(raw_ostream &os); + void printAsTextualPipeline(raw_ostream &os, bool filterVerifier = true); //===--------------------------------------------------------------------===// // Statistics diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h --- a/mlir/include/mlir/Pass/PassManager.h +++ b/mlir/include/mlir/Pass/PassManager.h @@ -104,7 +104,10 @@ /// of pipelines. /// Note: The quality of the string representation depends entirely on the /// the correctness of per-pass overrides of Pass::printAsTextualPipeline. - void printAsTextualPipeline(raw_ostream &os); + void printAsTextualPipeline(raw_ostream &os, bool filterVerifier = true); + + /// Raw dump of the pass manager to llvm::errs(). + void dump(); /// Merge the pass statistics of this class into 'other'. void mergeStatisticsInto(OpPassManager &other); diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -52,13 +52,13 @@ /// Prints out the pass in the textual representation of pipelines. If this is /// an adaptor pass, print with the op_name(sub_pass,...) format. -void Pass::printAsTextualPipeline(raw_ostream &os) { +void Pass::printAsTextualPipeline(raw_ostream &os, bool filterVerifier) { // Special case for adaptors to use the 'op_name(sub_passes)' format. if (auto *adaptor = dyn_cast(this)) { llvm::interleaveComma(adaptor->getPassManagers(), os, [&](OpPassManager &pm) { os << pm.getOpName() << "("; - pm.printAsTextualPipeline(os); + pm.printAsTextualPipeline(os, filterVerifier); os << ")"; }); return; @@ -74,7 +74,6 @@ passOptions.print(os); } - //===----------------------------------------------------------------------===// // Verifier Passes //===----------------------------------------------------------------------===// @@ -315,22 +314,31 @@ /// Prints out the given passes as the textual representation of a pipeline. static void printAsTextualPipeline(ArrayRef> passes, - raw_ostream &os) { + raw_ostream &os, + bool filterVerifier = true) { // Filter out passes that are not part of the public pipeline. auto filteredPasses = - llvm::make_filter_range(passes, [](const std::unique_ptr &pass) { - return !isa(pass); + llvm::make_filter_range(passes, [&](const std::unique_ptr &pass) { + return !filterVerifier || !isa(pass); }); llvm::interleaveComma(filteredPasses, os, [&](const std::unique_ptr &pass) { - pass->printAsTextualPipeline(os); + pass->printAsTextualPipeline(os, filterVerifier); }); } /// Prints out the passes of the pass manager as the textual representation /// of pipelines. -void OpPassManager::printAsTextualPipeline(raw_ostream &os) { - ::printAsTextualPipeline(impl->passes, os); +void OpPassManager::printAsTextualPipeline(raw_ostream &os, + bool filterVerifier) { + ::printAsTextualPipeline(impl->passes, os, filterVerifier); +} + +void OpPassManager::dump() { + llvm::errs() << "Pass Manager with " << impl->passes.size() << " passes: "; + ::printAsTextualPipeline(impl->passes, llvm::errs(), + /*filterVerifier=*/false); + llvm::errs() << "\n"; } static void registerDialectsForPipeline(const OpPassManager &pm,