Skip to content

Commit cdabce0

Browse files
authored
[MLIR] Remove extra 'any' from CompositePass inner pipeline string (llvm#139877)
When a `CompositePass` is created programmatically, it incorrectly prepends an extra `any` to the inner pipeline string. For example: ```c++ passManager.nestAny().addPass(createCompositeFixedPointPass( "Pass1AndPass2", [](OpPassManager &nestedPassManger) { nestedPassManger.addPass(createPass1()); nestedPassManger.addPass(createPass2()); }, ``` This would result in the following pipeline string: ``` any(composite-fixed-point-pass{max-iterations=3 name=Pass1AndPass2 pipeline=any(pass1,pass2)}) ``` This commit fixes this issue, resulting in the pipeline string: ``` any(composite-fixed-point-pass{max-iterations=3 name=Pass1AndPass2 pipeline=pass1,pass2}) ```
1 parent fb07683 commit cdabce0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

mlir/lib/Transforms/CompositePass.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ struct CompositeFixedPointPass final
3535
populateFunc(dynamicPM);
3636

3737
llvm::raw_string_ostream os(pipelineStr);
38-
dynamicPM.printAsTextualPipeline(os);
38+
llvm::interleave(
39+
dynamicPM, [&](mlir::Pass &pass) { pass.printAsTextualPipeline(os); },
40+
[&]() { os << ","; });
3941
}
4042

4143
LogicalResult initializeOptions(

mlir/test/Transforms/composite-pass.mlir

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
// RUN: mlir-opt %s --log-actions-to=- --test-composite-fixed-point-pass -split-input-file | FileCheck %s
1+
// RUN: mlir-opt %s --log-actions-to=- --test-composite-fixed-point-pass -split-input-file --dump-pass-pipeline 2>&1 | FileCheck %s --check-prefixes=CHECK,PIPELINE
22
// RUN: mlir-opt %s --log-actions-to=- --composite-fixed-point-pass='name=TestCompositePass pipeline=any(canonicalize,cse)' -split-input-file | FileCheck %s
33

4+
// Ensure the composite pass correctly prints its options.
5+
// PIPELINE: builtin.module(composite-fixed-point-pass{max-iterations=10 name=TestCompositePass
6+
// PIPELINE-SAME: pipeline=canonicalize{ max-iterations=10 max-num-rewrites=-1 region-simplify=normal test-convergence=false top-down=true},cse})
7+
48
// CHECK-LABEL: running `TestCompositePass`
59
// CHECK: running `Canonicalizer`
610
// CHECK: running `CSE`

0 commit comments

Comments
 (0)