Skip to content

Commit 3513267

Browse files
authored
[mlir] Add op printing flag to skip regions (llvm#77726)
The new flag, `--mlir-print-skip-regions`, sets the op printing option that disables region printing. This results in the usual `--mlir-print-ir-*` debug options printing only the names of the executed passes and the signatures of the ops. Example: ```mlir // -----// IR Dump Before CSE (cse) //----- // func.func @bar(%arg0: f32, %arg1: f32) -> f32 {...} // -----// IR Dump Before Canonicalizer (canonicalize) //----- // func.func @bar(%arg0: f32, %arg1: f32) -> f32 {...} ``` The main use-case is to be triage compilation issues (crashes, slowness) on very deep pass pipelines and with very large IR files, where printing IR is prohibitively slow otherwise.
1 parent 8fb8ad6 commit 3513267

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

mlir/lib/IR/AsmPrinter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ struct AsmPrinterOptions {
183183
llvm::cl::desc("Print with local scope and inline information (eliding "
184184
"aliases for attributes, types, and locations")};
185185

186+
llvm::cl::opt<bool> skipRegionsOpt{
187+
"mlir-print-skip-regions", llvm::cl::init(false),
188+
llvm::cl::desc("Skip regions when printing ops.")};
189+
186190
llvm::cl::opt<bool> printValueUsers{
187191
"mlir-print-value-users", llvm::cl::init(false),
188192
llvm::cl::desc(
@@ -217,6 +221,7 @@ OpPrintingFlags::OpPrintingFlags()
217221
printGenericOpFormFlag = clOptions->printGenericOpFormOpt;
218222
assumeVerifiedFlag = clOptions->assumeVerifiedOpt;
219223
printLocalScope = clOptions->printLocalScopeOpt;
224+
skipRegionsFlag = clOptions->skipRegionsOpt;
220225
printValueUsersFlag = clOptions->printValueUsers;
221226
}
222227

mlir/test/IR/print-skip-regions.mlir

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: mlir-opt --no-implicit-module --mlir-print-skip-regions \
2+
// RUN: --split-input-file %s | FileCheck %s
3+
4+
// CHECK-LABEL: func.func @foo(%{{.+}}: i32, %{{.+}}: i32, %{{.+}}: i32) -> i32 {...}
5+
// CHECK-NOT: return
6+
func.func @foo(%arg0: i32, %arg1: i32, %arg3: i32) -> i32 {
7+
return %arg0: i32
8+
}
9+
10+
// -----
11+
12+
// CHECK: module {...}
13+
// CHECK-NOT: func.func
14+
module {
15+
func.func @foo(%arg0: i32, %arg1: i32, %arg3: i32) -> i32 {
16+
return %arg0: i32
17+
}
18+
}

0 commit comments

Comments
 (0)