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,14 @@ 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(); + op->getContext()->printOpOnDiagnostic(false); + op->emitError() + << "A failure has been detected while processing the MLIR module, a " + "reproducer has been generated in '" + << *crashReproducerFileName << "'"; + op->getContext()->printOpOnDiagnostic(shouldPrintOnOp); + return failure(); } //===----------------------------------------------------------------------===//