diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -765,10 +765,16 @@ std::string error; if (failed(context.generate(error))) return op->emitError(": ") << error; - return op->emitError() - << "A failure has been detected while processing the MLIR module, a " - "reproducer has been generated in '" - << *crashReproducerFileName << "'"; + bool shouldPrintOnOp = op->getContext()->shouldPrintOpOnDiagnostic(); + if (shouldPrintOnOp) + op->getContext()->printOpOnDiagnostic(false); + op->emitError() + << "A failure has been detected while processing the MLIR module, a " + "reproducer has been generated in '" + << *crashReproducerFileName << "'"; + if (shouldPrintOnOp) + op->getContext()->printOpOnDiagnostic(true); + return failure(); } //===----------------------------------------------------------------------===//