diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -992,7 +992,7 @@ }; bool isEntryBlock = block.isEntryBlock(); - if (isEntryBlock) { + if (isEntryBlock && !printerFlags.shouldPrintGenericOpForm()) { if (auto *op = block.getParentOp()) { if (auto asmInterface = interfaces.getInterfaceFor(op->getDialect())) asmInterface->getAsmBlockArgumentNames(&block, setArgNameFn); @@ -1035,10 +1035,12 @@ if (int resultNo = result.cast().getResultNumber()) resultGroups.push_back(resultNo); }; - if (OpAsmOpInterface asmInterface = dyn_cast(&op)) - asmInterface.getAsmResultNames(setResultNameFn); - else if (auto *asmInterface = interfaces.getInterfaceFor(op.getDialect())) - asmInterface->getAsmResultNames(&op, setResultNameFn); + if (!printerFlags.shouldPrintGenericOpForm()) { + if (OpAsmOpInterface asmInterface = dyn_cast(&op)) + asmInterface.getAsmResultNames(setResultNameFn); + else if (auto *asmInterface = interfaces.getInterfaceFor(op.getDialect())) + asmInterface->getAsmResultNames(&op, setResultNameFn); + } // If the first result wasn't numbered, give it a default number. if (valueIDs.try_emplace(resultBegin, nextValueID).second) diff --git a/mlir/test/IR/print-op-generic.mlir b/mlir/test/IR/print-op-generic.mlir new file mode 100644 --- /dev/null +++ b/mlir/test/IR/print-op-generic.mlir @@ -0,0 +1,13 @@ +// # RUN: mlir-opt %s | FileCheck %s +// # RUN: mlir-opt %s --mlir-print-op-generic | FileCheck %s --check-prefix=GENERIC + +// CHECK-LABEL: func @pretty_names +// CHECK-GENERIC: "func"() +func @pretty_names() { + %x = test.string_attr_pretty_name + // CHECK: %x = test.string_attr_pretty_name + // GENERIC: %0 = "test.string_attr_pretty_name"() + return + // CHECK: return + // GENERIC: "std.return"() +}