diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index f0dd7c5178056..95d944170732e 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -322,6 +322,11 @@ class alignas(8) Operation final void print(raw_ostream &os, AsmState &state); void dump(); + // Dump pretty printed IR. This method is helpful for better readability if + // the Operation is not verified because it won't disable custom printers to + // fall back to the generic one. + LLVM_DUMP_METHOD void dumpPretty(); + //===--------------------------------------------------------------------===// // Operands //===--------------------------------------------------------------------===// diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 61b90bc9b0a7b..e97f5ed75a2ce 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -3985,6 +3985,11 @@ void Operation::dump() { llvm::errs() << "\n"; } +void Operation::dumpPretty() { + print(llvm::errs(), OpPrintingFlags().useLocalScope().assumeVerified()); + llvm::errs() << "\n"; +} + void Block::print(raw_ostream &os) { Operation *parentOp = getParentOp(); if (!parentOp) {