[Mlir-commits] [mlir] [mlir][Pass] Fix pipeline for crashless reproducer (PR #173750)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Dec 27 17:33:42 PST 2025


https://github.com/neildhar created https://github.com/llvm/llvm-project/pull/173750

Crashless reproducers currently emit an extra anchor op in the pipeline they print out, because one gets added by `appendReproducer`. Fix this by always adding the anchor op in the caller of `appendReproducer`.

In addition, `mlir-opt` always uses `any` as the anchor op, instead of getting the anchor op from the `PassManager`, fix that as well so we can test that the pipeline is reproduced as it was passed in.

>From 0cb45970e891d91ca7dfe16508dc09a5268c2cbe Mon Sep 17 00:00:00 2001
From: Neil Dhar <neildhar at meta.com>
Date: Sat, 27 Dec 2025 20:27:03 -0500
Subject: [PATCH] [mlir][Pass] Fix pipeline for crashless reproducer

Crashless reproducers currently emit an extra anchor op in the pipeline
they print out, because one gets added by `appendReproducer`. Fix this
by always adding the anchor op in the caller of `appendReproducer`.

In addition, `mlir-opt` always uses `any` as the anchor op, instead of
getting the anchor op from the `PassManager`, fix that as well so we can
test that the pipeline is reproduced as it was passed in.
---
 mlir/lib/Pass/PassCrashRecovery.cpp      | 13 +++++++------
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp  |  2 +-
 mlir/test/Pass/crashless-reproducer.mlir |  2 +-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/mlir/lib/Pass/PassCrashRecovery.cpp b/mlir/lib/Pass/PassCrashRecovery.cpp
index 3c9735f910094..70d1dc5b71d66 100644
--- a/mlir/lib/Pass/PassCrashRecovery.cpp
+++ b/mlir/lib/Pass/PassCrashRecovery.cpp
@@ -106,8 +106,8 @@ RecoveryReproducerContext::~RecoveryReproducerContext() {
 
 static void appendReproducer(std::string &description, Operation *op,
                              const ReproducerStreamFactory &factory,
-                             const std::string &pipelineElements,
-                             bool disableThreads, bool verifyPasses) {
+                             const std::string &pipeline, bool disableThreads,
+                             bool verifyPasses) {
   llvm::raw_string_ostream descOS(description);
 
   // Try to create a new output stream for this crash reproducer.
@@ -119,8 +119,6 @@ static void appendReproducer(std::string &description, Operation *op,
   }
   descOS << "reproducer generated at `" << stream->description() << "`";
 
-  std::string pipeline =
-      (op->getName().getStringRef() + "(" + pipelineElements + ")").str();
   AsmState state(op);
   state.attachResourcePrinter(
       "mlir_reproducer", [&](Operation *op, AsmResourceBuilder &builder) {
@@ -134,8 +132,11 @@ static void appendReproducer(std::string &description, Operation *op,
 }
 
 void RecoveryReproducerContext::generate(std::string &description) {
-  appendReproducer(description, preCrashOperation, streamFactory,
-                   pipelineElements, disableThreads, verifyPasses);
+  std::string pipeline = (preCrashOperation->getName().getStringRef() + "(" +
+                          pipelineElements + ")")
+                             .str();
+  appendReproducer(description, preCrashOperation, streamFactory, pipeline,
+                   disableThreads, verifyPasses);
 }
 
 void RecoveryReproducerContext::disable() {
diff --git a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index 018a188d09109..560ef6effd2fb 100644
--- a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -593,7 +593,7 @@ performActions(raw_ostream &os,
 
   // Generate reproducers if requested
   if (!config.getReproducerFilename().empty()) {
-    StringRef anchorName = pm.getAnyOpAnchorName();
+    StringRef anchorName = pm.getOpAnchorName();
     const auto &passes = pm.getPasses();
     makeReproducer(anchorName, passes, op.get(),
                    config.getReproducerFilename());
diff --git a/mlir/test/Pass/crashless-reproducer.mlir b/mlir/test/Pass/crashless-reproducer.mlir
index d874d90b8f3db..9f4710d392759 100644
--- a/mlir/test/Pass/crashless-reproducer.mlir
+++ b/mlir/test/Pass/crashless-reproducer.mlir
@@ -7,4 +7,4 @@ module @inner_mod1 {
 
 // REPRO: module @inner_mod1
 // REPRO: module @foo {
-// REPRO: pipeline: "builtin.module(any(builtin.module(test-module-pass)))"
+// REPRO: pipeline: "builtin.module(builtin.module(test-module-pass))"



More information about the Mlir-commits mailing list