Add a dump() method on the pass manager for debugging purpose (NFC)

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D88008
This commit is contained in:
Mehdi Amini 2020-09-23 05:50:05 +00:00
parent 00f6ebef6e
commit fe3c1195cf
3 changed files with 22 additions and 11 deletions

View file

@ -118,7 +118,7 @@ public:
/// 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

View file

@ -104,7 +104,10 @@ public:
/// 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);

View file

@ -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,