llvm / llvm/llvm-project

[mlir](remove-dead-values) mlir-opt crashes at RemoveDeadValues.cpp:203 with assertion `op->getNumResults() == toErase.size() && "expected the number of results in `op` and the size of `toErase` to " "be the same"' failed.

Open
#204,588 1 comment 0 reactions 0 assignees View on GitHub
crash mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

git version: 08b557bf5139394194be22359268b7b88f81faae

MLIR Program:
```mlir
module {
func.func private @callee(%arg0: memref) -> memref {
return %arg0 : memref
}
func.func @call_and_store_before(%arg0: memref) -> memref {
test.call_and_store @callee(%arg0), %arg0 {store_before_call = true, tag_name = "call"} : (memref, memref) -> ()
return {tag = "return"} %arg0 : memref
}
}
```

Reproduce Command: `mlir-opt -remove-dead-values a.mlir`

StackTrace:
```
mlir-opt: /data2/dependency/dev/llvm-project/mlir/lib/Transforms/RemoveDeadValues.cpp:203: void {anonymous}::dropUsesAndEraseResults(mlir::RewriterBase&, mlir::Operation*, llvm::BitVector): Assertion `op->getNumResults() == toErase.size() && "expected the number of results in `op` and the size of `toErase` to " "be the same"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /data2/dependency/dev/llvm-project/build/bin/mlir-opt -remove-dead-values a.mlir
#0 0x000055d2c8b94f6f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25bbf6f)
#1 0x000055d2c8b9173c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25b873c)
#2 0x000055d2c8b918d7 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f359a57f420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f359a06a00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f359a049859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f359a049729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f359a05afd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000055d2d187a358 (anonymous namespace)::cleanUpDeadVals(mlir::MLIRContext*, (anonymous namespace)::RDVFinalCleanupList&) RemoveDeadValues.cpp:0:0
#9 0x000055d2d1881079 (anonymous namespace)::RemoveDeadValues::runOnOperation() RemoveDeadValues.cpp:0:0
#10 0x000055d2d199bbf1 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3c2bf1)
#11 0x000055d2d199bf80 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3c2f80)
#12 0x000055d2d199e034 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3c5034)
#13 0x000055d2d199f0c1 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3c60c1)
#14 0x000055d2c8c5a86b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#15 0x000055d2c8c5b313 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#16 0x000055d2c8c5b59b llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#17 0x000055d2d1d76b45 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb79db45)
#18 0x000055d2c8c516a4 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#19 0x000055d2c8c5bab7 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2682ab7)
#20 0x000055d2c8c5bcf3 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2682cf3)
#21 0x000055d2c8ac1aec main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x24e8aec)
#22 0x00007f359a04b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#23 0x000055d2c8b7167e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x259867e)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Start with mlir/lib/Transforms/RemoveDeadValues.cpp, especially dropUsesAndEraseResults at the reported assertion near line 203, and reproduce the crash using the supplied MLIR program with mlir-opt -remove-dead-values. Trace why the result-removal list does not match the operation's results, then add a regression test showing that the reproducer completes without an assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.