[Mlir-commits] [mlir] fe3c119 - Add a dump() method on the pass manager for debugging purpose (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Tue Sep 22 22:53:50 PDT 2020
Author: Mehdi Amini
Date: 2020-09-23T05:53:41Z
New Revision: fe3c1195cfd027fdd28b6d373b3cd9519d5253ec
URL: https://github.com/llvm/llvm-project/commit/fe3c1195cfd027fdd28b6d373b3cd9519d5253ec
DIFF: https://github.com/llvm/llvm-project/commit/fe3c1195cfd027fdd28b6d373b3cd9519d5253ec.diff
LOG: Add a dump() method on the pass manager for debugging purpose (NFC)
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D88008
Added:
Modified:
mlir/include/mlir/Pass/Pass.h
mlir/include/mlir/Pass/PassManager.h
mlir/lib/Pass/Pass.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h
index e21e3e750270..70e1cd1b1163 100644
--- a/mlir/include/mlir/Pass/Pass.h
+++ b/mlir/include/mlir/Pass/Pass.h
@@ -118,7 +118,7 @@ class Pass {
/// 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
index 9b9214fd16c7..4008911e05af 100644
--- a/mlir/include/mlir/Pass/PassManager.h
+++ b/mlir/include/mlir/Pass/PassManager.h
@@ -104,7 +104,10 @@ class OpPassManager {
/// 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
index 7098b4bd4388..d84b71ccf59a 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -52,13 +52,13 @@ void Pass::copyOptionValuesFrom(const Pass *other) {
/// 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<OpToOpPassAdaptor>(this)) {
llvm::interleaveComma(adaptor->getPassManagers(), os,
[&](OpPassManager &pm) {
os << pm.getOpName() << "(";
- pm.printAsTextualPipeline(os);
+ pm.printAsTextualPipeline(os, filterVerifier);
os << ")";
});
return;
@@ -74,7 +74,6 @@ void Pass::printAsTextualPipeline(raw_ostream &os) {
passOptions.print(os);
}
-
//===----------------------------------------------------------------------===//
// Verifier Passes
//===----------------------------------------------------------------------===//
@@ -315,22 +314,31 @@ Identifier OpPassManager::getOpName(MLIRContext &context) const {
/// Prints out the given passes as the textual representation of a pipeline.
static void printAsTextualPipeline(ArrayRef<std::unique_ptr<Pass>> 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> &pass) {
- return !isa<VerifierPass>(pass);
+ llvm::make_filter_range(passes, [&](const std::unique_ptr<Pass> &pass) {
+ return !filterVerifier || !isa<VerifierPass>(pass);
});
llvm::interleaveComma(filteredPasses, os,
[&](const std::unique_ptr<Pass> &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,
More information about the Mlir-commits
mailing list