Skip to content

Commit fb16ed2

Browse files
committed
[mlir] Prefix pass manager options with mlir-
With this change, there's going to be a clear distinction between LLVM and MLIR pass maanger options (e.g. `-mlir-print-after-all` vs `-print-after-all`). This change is desirable from the point of view of projects that depend on both LLVM and MLIR, e.g. Flang. For consistency, all pass manager options in MLIR are prefixed with `mlir-`, even options that don't have equivalents in LLVM . Differential Revision: https://reviews.llvm.org/D123495
1 parent fa087b4 commit fb16ed2

File tree

13 files changed

+58
-57
lines changed

13 files changed

+58
-57
lines changed

mlir/docs/PassManagement.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@ infrastructure as
494494
[`llvm::Statistic`](http://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option)
495495
and thus have similar usage constraints. Collected statistics can be dumped by
496496
the [pass manager](#pass-manager) programmatically via
497-
`PassManager::enableStatistics`; or via `-pass-statistics` and
498-
`-pass-statistics-display` on the command line.
497+
`PassManager::enableStatistics`; or via `-mlir-pass-statistics` and
498+
`-mlir-pass-statistics-display` on the command line.
499499

500500
An example is shown below:
501501

@@ -534,7 +534,7 @@ A pipeline view that models the structure of the pass manager, this is the
534534
default view:
535535
536536
```shell
537-
$ mlir-opt -pass-pipeline='func.func(my-pass,my-pass)' foo.mlir -pass-statistics
537+
$ mlir-opt -pass-pipeline='func.func(my-pass,my-pass)' foo.mlir -mlir-pass-statistics
538538
539539
===-------------------------------------------------------------------------===
540540
... Pass statistics report ...
@@ -553,7 +553,7 @@ A list view that aggregates the statistics of all instances of a specific pass
553553
together:
554554

555555
```shell
556-
$ mlir-opt -pass-pipeline='func.func(my-pass, my-pass)' foo.mlir -pass-statistics -pass-statistics-display=list
556+
$ mlir-opt -pass-pipeline='func.func(my-pass, my-pass)' foo.mlir -mlir-pass-statistics -mlir-pass-statistics-display=list
557557

558558
===-------------------------------------------------------------------------===
559559
... Pass statistics report ...
@@ -1082,13 +1082,13 @@ instrumentation can be added directly to the PassManager via the
10821082
`enableIRPrinting` method. `mlir-opt` provides a few useful flags for utilizing
10831083
this instrumentation:
10841084

1085-
* `print-ir-before=(comma-separated-pass-list)`
1085+
* `mlir-print-ir-before=(comma-separated-pass-list)`
10861086
* Print the IR before each of the passes provided within the pass list.
1087-
* `print-ir-before-all`
1087+
* `mlir-print-ir-before-all`
10881088
* Print the IR before every pass in the pipeline.
10891089

10901090
```shell
1091-
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse)' -print-ir-before=cse
1091+
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse)' -mlir-print-ir-before=cse
10921092

10931093
*** IR Dump Before CSE ***
10941094
func @simple_constant() -> (i32, i32) {
@@ -1098,13 +1098,13 @@ func @simple_constant() -> (i32, i32) {
10981098
}
10991099
```
11001100

1101-
* `print-ir-after=(comma-separated-pass-list)`
1101+
* `mlir-print-ir-after=(comma-separated-pass-list)`
11021102
* Print the IR after each of the passes provided within the pass list.
1103-
* `print-ir-after-all`
1103+
* `mlir-print-ir-after-all`
11041104
* Print the IR after every pass in the pipeline.
11051105

11061106
```shell
1107-
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse)' -print-ir-after=cse
1107+
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse)' -mlir-print-ir-after=cse
11081108

11091109
*** IR Dump After CSE ***
11101110
func @simple_constant() -> (i32, i32) {
@@ -1113,19 +1113,19 @@ func @simple_constant() -> (i32, i32) {
11131113
}
11141114
```
11151115

1116-
* `print-ir-after-change`
1116+
* `mlir-print-ir-after-change`
11171117
* Only print the IR after a pass if the pass mutated the IR. This helps to
11181118
reduce the number of IR dumps for "uninteresting" passes.
11191119
* Note: Changes are detected by comparing a hash of the operation before
11201120
and after the pass. This adds additional run-time to compute the hash of
11211121
the IR, and in some rare cases may result in false-positives depending
11221122
on the collision rate of the hash algorithm used.
11231123
* Note: This option should be used in unison with one of the other
1124-
'print-ir-after' options above, as this option alone does not enable
1124+
'mlir-print-ir-after' options above, as this option alone does not enable
11251125
printing.
11261126

11271127
```shell
1128-
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse,cse)' -print-ir-after=cse -print-ir-after-change
1128+
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse,cse)' -mlir-print-ir-after=cse -mlir-print-ir-after-change
11291129

11301130
*** IR Dump After CSE ***
11311131
func @simple_constant() -> (i32, i32) {
@@ -1134,13 +1134,13 @@ func @simple_constant() -> (i32, i32) {
11341134
}
11351135
```
11361136

1137-
* `print-ir-after-failure`
1137+
* `mlir-print-ir-after-failure`
11381138
* Only print IR after a pass failure.
1139-
* This option should *not* be used with the other `print-ir-after` flags
1139+
* This option should *not* be used with the other `mlir-print-ir-after` flags
11401140
above.
11411141

11421142
```shell
1143-
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse,bad-pass)' -print-ir-failure
1143+
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse,bad-pass)' -mlir-print-ir-after-failure
11441144

11451145
*** IR Dump After BadPass Failed ***
11461146
func @simple_constant() -> (i32, i32) {
@@ -1149,14 +1149,14 @@ func @simple_constant() -> (i32, i32) {
11491149
}
11501150
```
11511151

1152-
* `print-ir-module-scope`
1152+
* `mlir-print-ir-module-scope`
11531153
* Always print the top-level module operation, regardless of pass type or
11541154
operation nesting level.
11551155
* Note: Printing at module scope should only be used when multi-threading
11561156
is disabled(`-mlir-disable-threading`)
11571157

11581158
```shell
1159-
$ mlir-opt foo.mlir -mlir-disable-threading -pass-pipeline='func.func(cse)' -print-ir-after=cse -print-ir-module-scope
1159+
$ mlir-opt foo.mlir -mlir-disable-threading -pass-pipeline='func.func(cse)' -mlir-print-ir-after=cse -mlir-print-ir-module-scope
11601160

11611161
*** IR Dump After CSE *** ('func.func' operation: @bar)
11621162
func @bar(%arg0: f32, %arg1: f32) -> f32 {
@@ -1186,7 +1186,7 @@ The [pass manager](#pass-manager) in MLIR contains a builtin mechanism to
11861186
generate reproducibles in the event of a crash, or a
11871187
[pass failure](#pass-failure). This functionality can be enabled via
11881188
`PassManager::enableCrashReproducerGeneration` or via the command line flag
1189-
`pass-pipeline-crash-reproducer`. In either case, an argument is provided that
1189+
`mlir-pass-pipeline-crash-reproducer`. In either case, an argument is provided that
11901190
corresponds to the output `.mlir` file name that the reproducible should be
11911191
written to. The reproducible contains the configuration of the pass manager that
11921192
was executing, as well as the initial IR before any passes were run. A potential
@@ -1214,7 +1214,7 @@ to its stream.
12141214

12151215
An additional flag may be passed to
12161216
`PassManager::enableCrashReproducerGeneration`, and specified via
1217-
`pass-pipeline-local-reproducer` on the command line, that signals that the pass
1217+
`mlir-pass-pipeline-local-reproducer` on the command line, that signals that the pass
12181218
manager should attempt to generate a "local" reproducer. This will attempt to
12191219
generate a reproducer containing IR right before the pass that fails. This is
12201220
useful for situations where the crash is known to be within a specific pass, or

mlir/docs/Tutorials/Toy/Ch-6.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ $ echo 'def main() { print([[1, 2], [3, 4]]); }' | ./bin/toyc-ch6 -emit=jit
324324

325325
You can also play with `-emit=mlir`, `-emit=mlir-affine`, `-emit=mlir-llvm`, and
326326
`-emit=llvm` to compare the various levels of IR involved. Also try options like
327-
[`--print-ir-after-all`](../../PassManagement.md/#ir-printing) to track the
327+
[`--mlir-print-ir-after-all`](../../PassManagement.md/#ir-printing) to track the
328328
evolution of the IR throughout the pipeline.
329329

330330
The example code used throughout this section can be found in

mlir/include/mlir-c/IR.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ mlirContextGetNumLoadedDialects(MlirContext context);
126126
MLIR_CAPI_EXPORTED MlirDialect mlirContextGetOrLoadDialect(MlirContext context,
127127
MlirStringRef name);
128128

129-
/// Set threading mode (must be set to false to print-ir-after-all).
129+
/// Set threading mode (must be set to false to mlir-print-ir-after-all).
130130
MLIR_CAPI_EXPORTED void mlirContextEnableMultithreading(MlirContext context,
131131
bool enable);
132132

mlir/include/mlir-c/Pass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ mlirPassManagerGetAsOpPassManager(MlirPassManager passManager);
7171
MLIR_CAPI_EXPORTED MlirLogicalResult
7272
mlirPassManagerRun(MlirPassManager passManager, MlirModule module);
7373

74-
/// Enable print-ir-after-all.
74+
/// Enable mlir-print-ir-after-all.
7575
MLIR_CAPI_EXPORTED void
7676
mlirPassManagerEnableIRPrinting(MlirPassManager passManager);
7777

mlir/lib/Bindings/Python/Pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void mlir::python::populatePassManagerSubmodule(py::module &m) {
7373
[](PyPassManager &passManager) {
7474
mlirPassManagerEnableIRPrinting(passManager.get());
7575
},
76-
"Enable print-ir-after-all.")
76+
"Enable mlir-print-ir-after-all.")
7777
.def(
7878
"enable_verifier",
7979
[](PyPassManager &passManager, bool enable) {

mlir/lib/Pass/PassManagerOptions.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,40 @@ struct PassManagerOptions {
2121
// Crash Reproducer Generator
2222
//===--------------------------------------------------------------------===//
2323
llvm::cl::opt<std::string> reproducerFile{
24-
"pass-pipeline-crash-reproducer",
24+
"mlir-pass-pipeline-crash-reproducer",
2525
llvm::cl::desc("Generate a .mlir reproducer file at the given output path"
2626
" if the pass manager crashes or fails")};
2727
llvm::cl::opt<bool> localReproducer{
28-
"pass-pipeline-local-reproducer",
28+
"mlir-pass-pipeline-local-reproducer",
2929
llvm::cl::desc("When generating a crash reproducer, attempt to generated "
3030
"a reproducer with the smallest pipeline."),
3131
llvm::cl::init(false)};
3232

3333
//===--------------------------------------------------------------------===//
3434
// IR Printing
3535
//===--------------------------------------------------------------------===//
36-
PassNameCLParser printBefore{"print-ir-before",
36+
PassNameCLParser printBefore{"mlir-print-ir-before",
3737
"Print IR before specified passes"};
38-
PassNameCLParser printAfter{"print-ir-after",
38+
PassNameCLParser printAfter{"mlir-print-ir-after",
3939
"Print IR after specified passes"};
4040
llvm::cl::opt<bool> printBeforeAll{
41-
"print-ir-before-all", llvm::cl::desc("Print IR before each pass"),
41+
"mlir-print-ir-before-all", llvm::cl::desc("Print IR before each pass"),
4242
llvm::cl::init(false)};
43-
llvm::cl::opt<bool> printAfterAll{"print-ir-after-all",
43+
llvm::cl::opt<bool> printAfterAll{"mlir-print-ir-after-all",
4444
llvm::cl::desc("Print IR after each pass"),
4545
llvm::cl::init(false)};
4646
llvm::cl::opt<bool> printAfterChange{
47-
"print-ir-after-change",
47+
"mlir-print-ir-after-change",
4848
llvm::cl::desc(
4949
"When printing the IR after a pass, only print if the IR changed"),
5050
llvm::cl::init(false)};
5151
llvm::cl::opt<bool> printAfterFailure{
52-
"print-ir-after-failure",
52+
"mlir-print-ir-after-failure",
5353
llvm::cl::desc(
5454
"When printing the IR after a pass, only print if the pass failed"),
5555
llvm::cl::init(false)};
5656
llvm::cl::opt<bool> printModuleScope{
57-
"print-ir-module-scope",
57+
"mlir-print-ir-module-scope",
5858
llvm::cl::desc("When printing IR for print-ir-[before|after]{-all} "
5959
"always print the top-level operation"),
6060
llvm::cl::init(false)};
@@ -66,9 +66,10 @@ struct PassManagerOptions {
6666
// Pass Statistics
6767
//===--------------------------------------------------------------------===//
6868
llvm::cl::opt<bool> passStatistics{
69-
"pass-statistics", llvm::cl::desc("Display the statistics of each pass")};
69+
"mlir-pass-statistics",
70+
llvm::cl::desc("Display the statistics of each pass")};
7071
llvm::cl::opt<PassDisplayMode> passStatisticsDisplayMode{
71-
"pass-statistics-display",
72+
"mlir-pass-statistics-display",
7273
llvm::cl::desc("Display method for pass statistics"),
7374
llvm::cl::init(PassDisplayMode::Pipeline),
7475
llvm::cl::values(

mlir/test/Pass/crash-recovery-dynamic-failure.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Check that local reproducers will also traverse dynamic pass pipelines.
2-
// RUN: mlir-opt %s -pass-pipeline='test-module-pass,test-dynamic-pipeline{op-name=inner_mod1 run-on-nested-operations=1 dynamic-pipeline=test-pass-failure}' -pass-pipeline-crash-reproducer=%t -verify-diagnostics -pass-pipeline-local-reproducer --mlir-disable-threading
2+
// RUN: mlir-opt %s -pass-pipeline='test-module-pass,test-dynamic-pipeline{op-name=inner_mod1 run-on-nested-operations=1 dynamic-pipeline=test-pass-failure}' -mlir-pass-pipeline-crash-reproducer=%t -verify-diagnostics -mlir-pass-pipeline-local-reproducer --mlir-disable-threading
33
// RUN: cat %t | FileCheck -check-prefix=REPRO_LOCAL_DYNAMIC_FAILURE %s
44

55
// The crash recovery mechanism will leak memory allocated in the crashing thread.

mlir/test/Pass/crash-recovery.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-module-pass, test-pass-crash)' -pass-pipeline-crash-reproducer=%t -verify-diagnostics
1+
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-module-pass, test-pass-crash)' -mlir-pass-pipeline-crash-reproducer=%t -verify-diagnostics
22
// RUN: cat %t | FileCheck -check-prefix=REPRO %s
3-
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-module-pass, test-pass-crash)' -pass-pipeline-crash-reproducer=%t -verify-diagnostics -pass-pipeline-local-reproducer -mlir-disable-threading
3+
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-module-pass, test-pass-crash)' -mlir-pass-pipeline-crash-reproducer=%t -verify-diagnostics -mlir-pass-pipeline-local-reproducer -mlir-disable-threading
44
// RUN: cat %t | FileCheck -check-prefix=REPRO_LOCAL %s
55

66
// Check that we correctly handle verifiers passes with local reproducer, this used to crash.
7-
// RUN: mlir-opt %s -test-module-pass -test-module-pass -test-module-pass -pass-pipeline-crash-reproducer=%t -pass-pipeline-local-reproducer -mlir-disable-threading
7+
// RUN: mlir-opt %s -test-module-pass -test-module-pass -test-module-pass -mlir-pass-pipeline-crash-reproducer=%t -mlir-pass-pipeline-local-reproducer -mlir-disable-threading
88
// RUN: cat %t | FileCheck -check-prefix=REPRO_LOCAL %s
99

1010
// Check that local reproducers will also traverse dynamic pass pipelines.
11-
// RUN: mlir-opt %s -pass-pipeline='test-module-pass,test-dynamic-pipeline{op-name=inner_mod1 run-on-nested-operations=1 dynamic-pipeline=test-pass-crash}' -pass-pipeline-crash-reproducer=%t -verify-diagnostics -pass-pipeline-local-reproducer --mlir-disable-threading
11+
// RUN: mlir-opt %s -pass-pipeline='test-module-pass,test-dynamic-pipeline{op-name=inner_mod1 run-on-nested-operations=1 dynamic-pipeline=test-pass-crash}' -mlir-pass-pipeline-crash-reproducer=%t -verify-diagnostics -mlir-pass-pipeline-local-reproducer --mlir-disable-threading
1212
// RUN: cat %t | FileCheck -check-prefix=REPRO_LOCAL_DYNAMIC %s
1313

1414
// The crash recovery mechanism will leak memory allocated in the crashing thread.

mlir/test/Pass/dynamic-pipeline-nested.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod1 dynamic-pipeline=cse})' --mlir-disable-threading -print-ir-before-all 2>&1 | FileCheck %s --check-prefix=NOTNESTED --check-prefix=CHECK
2-
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod1 run-on-nested-operations=1 dynamic-pipeline=cse})' --mlir-disable-threading -print-ir-before-all 2>&1 | FileCheck %s --check-prefix=NESTED --check-prefix=CHECK
1+
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod1 dynamic-pipeline=cse})' --mlir-disable-threading -mlir-print-ir-before-all 2>&1 | FileCheck %s --check-prefix=NOTNESTED --check-prefix=CHECK
2+
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod1 run-on-nested-operations=1 dynamic-pipeline=cse})' --mlir-disable-threading -mlir-print-ir-before-all 2>&1 | FileCheck %s --check-prefix=NESTED --check-prefix=CHECK
33

44

55
// Verify that we can schedule a dynamic pipeline on a nested operation
@@ -12,7 +12,7 @@ func @f() {
1212
// CHECK-SAME: TestDynamicPipelinePass
1313
// CHECK-NEXT: module @inner_mod1
1414
module @inner_mod1 {
15-
// We use the print-ir-after-all dumps to check the granularity of the
15+
// We use the mlir-print-ir-after-all dumps to check the granularity of the
1616
// scheduling: if we are nesting we expect to see to individual "Dump Before
1717
// CSE" output: one for each of the function. If we don't nest, then we expect
1818
// the CSE pass to run on the `inner_mod1` module directly.

mlir/test/Pass/dynamic-pipeline.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod1, dynamic-pipeline=func.func(cse,canonicalize)})' --mlir-disable-threading -print-ir-before-all 2>&1 | FileCheck %s --check-prefix=MOD1 --check-prefix=MOD1-ONLY --check-prefix=CHECK
2-
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod2, dynamic-pipeline=func.func(cse,canonicalize)})' --mlir-disable-threading -print-ir-before-all 2>&1 | FileCheck %s --check-prefix=MOD2 --check-prefix=MOD2-ONLY --check-prefix=CHECK
3-
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod1,inner_mod2, dynamic-pipeline=func.func(cse,canonicalize)})' --mlir-disable-threading -print-ir-before-all 2>&1 | FileCheck %s --check-prefix=MOD1 --check-prefix=MOD2 --check-prefix=CHECK
4-
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{dynamic-pipeline=func.func(cse,canonicalize)})' --mlir-disable-threading -print-ir-before-all 2>&1 | FileCheck %s --check-prefix=MOD1 --check-prefix=MOD2 --check-prefix=CHECK
1+
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod1, dynamic-pipeline=func.func(cse,canonicalize)})' --mlir-disable-threading -mlir-print-ir-before-all 2>&1 | FileCheck %s --check-prefix=MOD1 --check-prefix=MOD1-ONLY --check-prefix=CHECK
2+
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod2, dynamic-pipeline=func.func(cse,canonicalize)})' --mlir-disable-threading -mlir-print-ir-before-all 2>&1 | FileCheck %s --check-prefix=MOD2 --check-prefix=MOD2-ONLY --check-prefix=CHECK
3+
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{op-name=inner_mod1,inner_mod2, dynamic-pipeline=func.func(cse,canonicalize)})' --mlir-disable-threading -mlir-print-ir-before-all 2>&1 | FileCheck %s --check-prefix=MOD1 --check-prefix=MOD2 --check-prefix=CHECK
4+
// RUN: mlir-opt %s -pass-pipeline='builtin.module(test-dynamic-pipeline{dynamic-pipeline=func.func(cse,canonicalize)})' --mlir-disable-threading -mlir-print-ir-before-all 2>&1 | FileCheck %s --check-prefix=MOD1 --check-prefix=MOD2 --check-prefix=CHECK
55

66

77
func @f() {

0 commit comments

Comments
 (0)