<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116364>116364</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]`-remove-dead-values` triggers crash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xisang0
</td>
</tr>
</table>
<pre>
Test on commit: https://github.com/llvm/llvm-project/commit/6548b6354d1d990e1c98736f5e7c3de876bedc8e
steps to reproduce:
```
mlir-opt test.mlir --remove-dead-values
```
test case:
```
module {
spirv.func @const() -> !spirv.array<6 x i32> "None" {
%cst = spirv.Constant dense<0> : tensor<6xi32> : !spirv.array<6 x i32>
spirv.ReturnValue %cst : !spirv.array<6 x i32>
}
}
```
crash trace:
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./mlir-opt /home/workdir/test.mlir --remove-dead-values
#0 0x000062921ac913b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x10723b8)
#1 0x000062921ac8eede llvm::sys::RunSignalHandlers() (./mlir-opt+0x106fede)
#2 0x000062921ac91dc8 SignalHandler(int) Signals.cpp:0:0
#3 0x000075736ed03520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000062921cff41ff mlir::WalkResult llvm::function_ref<mlir::WalkResult (mlir::Operation*)>::callback_fn<mlir::spirv::FuncOp::verifyBody()::$_0>(long, mlir::Operation*) SPIRVOps.cpp:0:0
#5 0x000062921adb0b37 mlir::WalkResult mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<mlir::WalkResult (mlir::Operation*)>, mlir::WalkOrder) (./mlir-opt+0x1191b37)
#6 0x000062921cfebabb mlir::spirv::FuncOp::verifyBody() (./mlir-opt+0x33ccabb)
#7 0x000062921cda9900 llvm::LogicalResult mlir::function_interface_impl::verifyTrait<mlir::spirv::FuncOp>(mlir::spirv::FuncOp) (./mlir-opt+0x318a900)
#8 0x000062921cda91b1 llvm::LogicalResult mlir::op_definition_impl::verifyTraits<mlir::OpTrait::OneRegion<mlir::spirv::FuncOp>, mlir::OpTrait::ZeroResults<mlir::spirv::FuncOp>, mlir::OpTrait::ZeroSuccessors<mlir::spirv::FuncOp>, mlir::OpTrait::ZeroOperands<mlir::spirv::FuncOp>, mlir::OpTrait::OpInvariants<mlir::spirv::FuncOp>, mlir::BytecodeOpInterface::Trait<mlir::spirv::FuncOp>, mlir::OpTrait::AutomaticAllocationScope<mlir::spirv::FuncOp>, mlir::SymbolOpInterface::Trait<mlir::spirv::FuncOp>, mlir::CallableOpInterface::Trait<mlir::spirv::FuncOp>, mlir::FunctionOpInterface::Trait<mlir::spirv::FuncOp>, mlir::OpTrait::IsIsolatedFromAbove<mlir::spirv::FuncOp>, mlir::detail::Interface<mlir::spirv::QueryMinVersionInterface, mlir::Operation*, mlir::spirv::detail::QueryMinVersionInterfaceTraits, mlir::Op<mlir::spirv::QueryMinVersionInterface>, mlir::OpTrait::TraitBase>::Trait<mlir::spirv::FuncOp>, mlir::detail::Interface<mlir::spirv::QueryMaxVersionInterface, mlir::Operation*, mlir::spirv::detail::QueryMaxVersionInterfaceTraits, mlir::Op<mlir::spirv::QueryMaxVersionInterface>, mlir::OpTrait::TraitBase>::Trait<mlir::spirv::FuncOp>, mlir::detail::Interface<mlir::spirv::QueryExtensionInterface, mlir::Operation*, mlir::spirv::detail::QueryExtensionInterfaceTraits, mlir::Op<mlir::spirv::QueryExtensionInterface>, mlir::OpTrait::TraitBase>::Trait<mlir::spirv::FuncOp>, mlir::detail::Interface<mlir::spirv::QueryCapabilityInterface, mlir::Operation*, mlir::spirv::detail::QueryCapabilityInterfaceTraits, mlir::Op<mlir::spirv::QueryCapabilityInterface>, mlir::OpTrait::TraitBase>::Trait<mlir::spirv::FuncOp>>(mlir::Operation*) (./mlir-opt+0x318a1b1)
#9 0x000062921cda9070 mlir::Op<mlir::spirv::FuncOp, mlir::OpTrait::OneRegion, mlir::OpTrait::ZeroResults, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::ZeroOperands, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::OpTrait::AutomaticAllocationScope, mlir::SymbolOpInterface::Trait, mlir::CallableOpInterface::Trait, mlir::FunctionOpInterface::Trait, mlir::OpTrait::IsIsolatedFromAbove, mlir::detail::Interface<mlir::spirv::QueryMinVersionInterface, mlir::Operation*, mlir::spirv::detail::QueryMinVersionInterfaceTraits, mlir::Op<mlir::spirv::QueryMinVersionInterface>, mlir::OpTrait::TraitBase>::Trait, mlir::detail::Interface<mlir::spirv::QueryMaxVersionInterface, mlir::Operation*, mlir::spirv::detail::QueryMaxVersionInterfaceTraits, mlir::Op<mlir::spirv::QueryMaxVersionInterface>, mlir::OpTrait::TraitBase>::Trait, mlir::detail::Interface<mlir::spirv::QueryExtensionInterface, mlir::Operation*, mlir::spirv::detail::QueryExtensionInterfaceTraits, mlir::Op<mlir::spirv::QueryExtensionInterface>, mlir::OpTrait::TraitBase>::Trait, mlir::detail::Interface<mlir::spirv::QueryCapabilityInterface, mlir::Operation*, mlir::spirv::detail::QueryCapabilityInterfaceTraits, mlir::Op<mlir::spirv::QueryCapabilityInterface>, mlir::OpTrait::TraitBase>::Trait>::verifyInvariants(mlir::Operation*) (./mlir-opt+0x318a070)
#10 0x000062921cda6160 mlir::RegisteredOperationName::Model<mlir::spirv::FuncOp>::verifyInvariants(mlir::Operation*) (./mlir-opt+0x3187160)
#11 0x000062921e0cf59a (anonymous namespace)::OperationVerifier::verifyOpAndDominance(mlir::Operation&) Verifier.cpp:0:0
#12 0x000062921e0cf6d0 (anonymous namespace)::OperationVerifier::verifyOpAndDominance(mlir::Operation&) Verifier.cpp:0:0
#13 0x000062921e0cec86 mlir::verify(mlir::Operation*, bool) (./mlir-opt+0x44afc86)
#14 0x000062921df0da3e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x42eea3e)
#15 0x000062921df0dec2 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x42eeec2)
#16 0x000062921df1066e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x42f166e)
#17 0x000062921df09192 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x000062921df08dfb llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#19 0x000062921dfb2ae5 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (./mlir-opt+0x4393ae5)
#20 0x000062921df03ff2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x42e4ff2)
#21 0x000062921df042a3 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42e52a3)
#22 0x000062921df044b2 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42e54b2)
#23 0x000062921ac705d7 main (./mlir-opt+0x10515d7)
#24 0x000075736ecead90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#25 0x000075736eceae40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#26 0x000062921ac70145 _start (./mlir-opt+0x1051145)
Segmentation fault (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1v2zrS_jXMDRGDor4vcuE4Md4AJyd5k6IL7I1BkSOHW4nUklQa__sFJce2HCu1c1Jsd7dFi8oSOfPMMzOcEUVmrVwqgAsUX6L46oy17kmbixdpmVqSs0KL1cUXsA5rhbmua-lQOMVPzjUWhVNE54jOl9I9tcWE6xrReVU9v_533hj9D-AO0fl6Kp0ncZQVSRhHIhB5TiDgeZaGSRlDykMBWZoUIHgGiFwhMrUOGoudxgYao0XLwSvtHqGErP92P-tKmnPdOOzAuon_hc_PDdT6Gc4FMHH-zKoW7MG5fgrmzI4L16KtAKP0sv-NsW2keZ6UreIYRYRrZR2iGaI5PkfhNUY06EcwY9gKhbMEv2AZ0v4Z_VMrQJTuCsQY0Zhbh1F4tZY-81KZcliA8thmpJseTrEDZbXxYl9ehYbT95RutfQjHsC1Rn31lGz1HiUBpVdrijYXQ664YfYJO8PGfXX_x_X08RrbtqilwwwX7dI7WBvnXX1ybElrvWfpHDMlsFS8agVg9wS4x1Iw_q3DM-nVPzrGv2HR1s0GIJng7s-90UvDaszMsq1BOY8DTxCdb8IL0fmTrgHR-XdtvglpEJ0fE3IY0ZBg8kIIIQnNacB4HoRFhjubwikKp3Zl-4t7I5XrUH7paKTZdpBh3xfaOgOsRjRBdIalcj7uEM12gSJ6SV4CktKw8GG5BREMQWQAAg6BeGjVo1wqVv0fU6ICY9fxfVhPUoKAgR66b6zgGR5IR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