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 @@ virtual LogicalResult initializeOptions(StringRef options); /// Prints out the pass in the textual representation of pipelines. If this is - /// an adaptor pass, print with the op_name(sub_pass,...) format. + /// an adaptor pass, print its pass managers. void printAsTextualPipeline(raw_ostream &os); //===--------------------------------------------------------------------===// 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 @@ -50,17 +50,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. +/// an adaptor pass, print its pass managers. void Pass::printAsTextualPipeline(raw_ostream &os) { - // Special case for adaptors to use the 'op_name(sub_passes)' format. + // Special case for adaptors to print its pass managers. if (auto *adaptor = dyn_cast(this)) { llvm::interleave( adaptor->getPassManagers(), - [&](OpPassManager &pm) { - os << pm.getOpAnchorName() << "("; - pm.printAsTextualPipeline(os); - os << ")"; - }, + [&](OpPassManager &pm) { pm.printAsTextualPipeline(os); }, [&] { os << ","; }); return; } @@ -355,26 +351,22 @@ return impl->getOpAnchorName(); } -/// Prints out the given passes as the textual representation of a pipeline. -static void printAsTextualPipeline(ArrayRef> passes, - raw_ostream &os) { +/// Prints out the passes of the pass manager as the textual representation +/// of pipelines. +void OpPassManager::printAsTextualPipeline(raw_ostream &os) const { + os << getOpAnchorName() << "("; llvm::interleave( - passes, + impl->passes, [&](const std::unique_ptr &pass) { pass->printAsTextualPipeline(os); }, - [&] { os << ","; }); -} - -/// Prints out the passes of the pass manager as the textual representation -/// of pipelines. -void OpPassManager::printAsTextualPipeline(raw_ostream &os) const { - ::printAsTextualPipeline(impl->passes, os); + [&]() { os << ","; }); + os << ")"; } void OpPassManager::dump() { llvm::errs() << "Pass Manager with " << impl->passes.size() << " passes: "; - ::printAsTextualPipeline(impl->passes, llvm::errs()); + printAsTextualPipeline(llvm::errs()); llvm::errs() << "\n"; } diff --git a/mlir/test/CAPI/pass.c b/mlir/test/CAPI/pass.c --- a/mlir/test/CAPI/pass.c +++ b/mlir/test/CAPI/pass.c @@ -145,20 +145,22 @@ mlirOpPassManagerAddOwnedPass(nestedFuncPm, printOpStatPass); // Print the top level pass manager - // CHECK: Top-level: builtin.module(func.func(print-op-stats{json=false})) + // CHECK: Top-level: builtin.module( + // CHECK-SAME: builtin.module(func.func(print-op-stats{json=false})) + // CHECK-SAME: ) fprintf(stderr, "Top-level: "); mlirPrintPassPipeline(mlirPassManagerGetAsOpPassManager(pm), printToStderr, NULL); fprintf(stderr, "\n"); // Print the pipeline nested one level down - // CHECK: Nested Module: func.func(print-op-stats{json=false}) + // CHECK: Nested Module: builtin.module(func.func(print-op-stats{json=false})) fprintf(stderr, "Nested Module: "); mlirPrintPassPipeline(nestedModulePm, printToStderr, NULL); fprintf(stderr, "\n"); // Print the pipeline nested two levels down - // CHECK: Nested Module>Func: print-op-stats + // CHECK: Nested Module>Func: func.func(print-op-stats{json=false}) fprintf(stderr, "Nested Module>Func: "); mlirPrintPassPipeline(nestedFuncPm, printToStderr, NULL); fprintf(stderr, "\n"); @@ -197,8 +199,10 @@ exit(EXIT_FAILURE); } - // CHECK: Round-trip: builtin.module(func.func(print-op-stats{json=false}), - // func.func(print-op-stats{json=false})) + // CHECK: Round-trip: builtin.module(builtin.module( + // CHECK-SAME: func.func(print-op-stats{json=false}), + // CHECK-SAME: func.func(print-op-stats{json=false}) + // CHECK-SAME: )) fprintf(stderr, "Round-trip: "); mlirPrintPassPipeline(mlirPassManagerGetAsOpPassManager(pm), printToStderr, NULL); diff --git a/mlir/test/Pass/pipeline-options-parsing.mlir b/mlir/test/Pass/pipeline-options-parsing.mlir --- a/mlir/test/Pass/pipeline-options-parsing.mlir +++ b/mlir/test/Pass/pipeline-options-parsing.mlir @@ -14,4 +14,4 @@ // CHECK_1: test-options-pass{list=1,2,3,4,5 string=nested_pipeline{arg1=10 arg2=" {} " arg3=true} string-list=a,b,c,d} // CHECK_2: test-options-pass{list=1 string= string-list=a,b} -// CHECK_3: builtin.module(func.func(test-options-pass{list=3 string= }),func.func(test-options-pass{list=1,2,3,4 string= })) +// CHECK_3: builtin.module(builtin.module(func.func(test-options-pass{list=3 string= }),func.func(test-options-pass{list=1,2,3,4 string= }))) diff --git a/mlir/test/python/pass_manager.py b/mlir/test/python/pass_manager.py --- a/mlir/test/python/pass_manager.py +++ b/mlir/test/python/pass_manager.py @@ -46,7 +46,7 @@ # A registered pass should parse successfully. pm = PassManager.parse("builtin.module(func.func(print-op-stats{json=false}))") - # CHECK: Roundtrip: builtin.module(func.func(print-op-stats{json=false})) + # CHECK: Roundtrip: builtin.module(builtin.module(func.func(print-op-stats{json=false}))) log("Roundtrip: ", pm) run(testParseSuccess)