Skip to content

Commit 702f06a

Browse files
committed
Fix crash in the pass pipeline when local reproducer is enabled
This crash only happens when a function pass is followed by a module pass. In this case the splitting of the pass pipeline didn't handle properly the verifier passes and ended up with an odd number of pass in the pipeline, breaking an assumption of the local crash reproducer executor and hitting an assertion. Differential Revision: https://reviews.llvm.org/D88000
1 parent 57ae9bb commit 702f06a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

mlir/lib/Pass/Pass.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,14 @@ void OpPassManagerImpl::splitAdaptorPasses() {
227227
std::swap(passes, oldPasses);
228228

229229
for (std::unique_ptr<Pass> &pass : oldPasses) {
230+
// Ignore verifier passes, they are added back in the "addPass()" calls.
231+
if (isa<VerifierPass>(pass.get()))
232+
continue;
233+
230234
// If this pass isn't an adaptor, move it directly to the new pass list.
231235
auto *currentAdaptor = dyn_cast<OpToOpPassAdaptor>(pass.get());
232236
if (!currentAdaptor) {
233-
passes.push_back(std::move(pass));
237+
addPass(std::move(pass));
234238
continue;
235239
}
236240

mlir/test/Pass/crash-recovery.mlir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: mlir-opt %s -pass-pipeline='func(test-function-pass, test-pass-crash)' -pass-pipeline-crash-reproducer=%t -verify-diagnostics -pass-pipeline-local-reproducer
44
// RUN: cat %t | FileCheck -check-prefix=REPRO_LOCAL %s
55

6+
// Check that we correctly handle verifiers passes with local reproducer, this use to crash.
7+
// RUN: mlir-opt %s -test-function-pass -test-function-pass -test-module-pass -pass-pipeline-crash-reproducer=%t -pass-pipeline-local-reproducer
8+
69
// expected-error@+1 {{A failure has been detected while processing the MLIR module}}
710
module {
811
func @foo() {

0 commit comments

Comments
 (0)