Skip to content

Commit 644643a

Browse files
authored
[mlir] Add Operation::dumpPrettyPrinted (#120117)
- [x] Add `Operation::dumpPrettyPrinted` to get more readable print during debugging when the IR may not be able to pass verify yet.
1 parent db09014 commit 644643a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

mlir/include/mlir/IR/Operation.h

+5
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ class alignas(8) Operation final
322322
void print(raw_ostream &os, AsmState &state);
323323
void dump();
324324

325+
// Dump pretty printed IR. This method is helpful for better readability if
326+
// the Operation is not verified because it won't disable custom printers to
327+
// fall back to the generic one.
328+
LLVM_DUMP_METHOD void dumpPretty();
329+
325330
//===--------------------------------------------------------------------===//
326331
// Operands
327332
//===--------------------------------------------------------------------===//

mlir/lib/IR/AsmPrinter.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -4019,6 +4019,11 @@ void Operation::dump() {
40194019
llvm::errs() << "\n";
40204020
}
40214021

4022+
void Operation::dumpPretty() {
4023+
print(llvm::errs(), OpPrintingFlags().useLocalScope().assumeVerified());
4024+
llvm::errs() << "\n";
4025+
}
4026+
40224027
void Block::print(raw_ostream &os) {
40234028
Operation *parentOp = getParentOp();
40244029
if (!parentOp) {

0 commit comments

Comments
 (0)