@@ -82,12 +82,12 @@ void Pass::copyOptionValuesFrom(const Pass *other) {
8282
8383// / Prints out the pass in the textual representation of pipelines. If this is
8484// / an adaptor pass, print its pass managers.
85- void Pass::printAsTextualPipeline (raw_ostream &os) {
85+ void Pass::printAsTextualPipeline (raw_ostream &os, bool pretty ) {
8686 // Special case for adaptors to print its pass managers.
8787 if (auto *adaptor = dyn_cast<OpToOpPassAdaptor>(this )) {
8888 llvm::interleave (
8989 adaptor->getPassManagers (),
90- [&](OpPassManager &pm) { pm.printAsTextualPipeline (os); },
90+ [&](OpPassManager &pm) { pm.printAsTextualPipeline (os, pretty ); },
9191 [&] { os << " ," ; });
9292 return ;
9393 }
@@ -394,14 +394,24 @@ StringRef OpPassManager::getOpAnchorName() const {
394394// / of pipelines.
395395void printAsTextualPipeline (
396396 raw_indented_ostream &os, StringRef anchorName,
397- const llvm::iterator_range<OpPassManager::pass_iterator> &passes) {
398- os << anchorName << " (\n " ;
399- os.indent ();
397+ const llvm::iterator_range<OpPassManager::pass_iterator> &passes,
398+ bool pretty = false ) {
399+ os << anchorName << " (" ;
400+ if (pretty) {
401+ os << " \n " ;
402+ os.indent ();
403+ }
400404 llvm::interleave (
401405 passes, [&](mlir::Pass &pass) { pass.printAsTextualPipeline (os); },
402- [&]() { os << " ,\n " ; });
403- os << " \n " ;
404- os.unindent ();
406+ [&]() {
407+ os << " ," ;
408+ if (pretty)
409+ os << " \n " ;
410+ });
411+ if (pretty) {
412+ os << " \n " ;
413+ os.unindent ();
414+ }
405415 os << " )" ;
406416}
407417void printAsTextualPipeline (
@@ -410,18 +420,19 @@ void printAsTextualPipeline(
410420 raw_indented_ostream indentedOS (os);
411421 printAsTextualPipeline (indentedOS, anchorName, passes);
412422}
413- void OpPassManager::printAsTextualPipeline (raw_ostream &os) const {
423+ void OpPassManager::printAsTextualPipeline (raw_ostream &os, bool pretty ) const {
414424 StringRef anchorName = getOpAnchorName ();
415425 raw_indented_ostream indentedOS (os);
416426 ::printAsTextualPipeline (
417427 indentedOS, anchorName,
418428 {MutableArrayRef<std::unique_ptr<Pass>>{impl->passes }.begin (),
419- MutableArrayRef<std::unique_ptr<Pass>>{impl->passes }.end ()});
429+ MutableArrayRef<std::unique_ptr<Pass>>{impl->passes }.end ()},
430+ pretty);
420431}
421432
422433void OpPassManager::dump () {
423434 llvm::errs () << " Pass Manager with " << impl->passes .size () << " passes:\n " ;
424- printAsTextualPipeline (llvm::errs ());
435+ printAsTextualPipeline (llvm::errs (), /* pretty= */ true );
425436 llvm::errs () << " \n " ;
426437}
427438
@@ -477,7 +488,6 @@ llvm::hash_code OpPassManager::hash() {
477488 return hashCode;
478489}
479490
480-
481491// ===----------------------------------------------------------------------===//
482492// OpToOpPassAdaptor
483493// ===----------------------------------------------------------------------===//
@@ -882,7 +892,8 @@ LogicalResult PassManager::run(Operation *op) {
882892 // Initialize all of the passes within the pass manager with a new generation.
883893 llvm::hash_code newInitKey = context->getRegistryHash ();
884894 llvm::hash_code pipelineKey = hash ();
885- if (newInitKey != initializationKey || pipelineKey != pipelineInitializationKey) {
895+ if (newInitKey != initializationKey ||
896+ pipelineKey != pipelineInitializationKey) {
886897 if (failed (initialize (context, impl->initializationGeneration + 1 )))
887898 return failure ();
888899 initializationKey = newInitKey;
0 commit comments