<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74306>74306</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] --inline crashed in SimplifyClones::matchAndRewrite with assertion failure "dyn_cast on a non-existent value".
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
anonymousMCS
</td>
</tr>
</table>
<pre>
git version: e9c6f3f5e7e23b23de4eeaa182ebfcb7d2188495
system: ```Ubuntu 20.04.6 LTS (Focal Fossa)```
reproduced with: ```mlir-opt --inline a.mlir```
a.mlir:
```
func.func @func2() {
%c6 = arith.constant 6 : index
%c29 = arith.constant 29 : index
%3 = tensor.empty() : tensor<11x13xf32>
%alloc_10 = memref.alloc() : memref<11x13xi64>
memref.dealloc %alloc_10 : memref<11x13xi64>
%102 = bufferization.clone %alloc_10 : memref<11x13xi64> to memref<11x13xi64>
%147 = affine.load %102[%c29, %c6] : memref<11x13xi64>
return
}
```
trace:
```
mlir-opt: /data/bin/llvm-project/llvm/include/llvm/Support/Casting.h:662: decltype(auto) llvm::dyn_cast(From*) [with To = mlir::MemoryEffectOpInterface; From = mlir::Operation]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /data/bin/llvm-project/build/bin/mlir-opt --inline a.mlir
#0 0x000055d8d8856e6f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x1640e6f)
#1 0x000055d8d8853ec4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007fe909a70420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007fe90955b00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007fe90953a859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007fe90953a729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007fe90954bfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x000055d8d8d272d8 (anonymous namespace)::SimplifyClones::matchAndRewrite(mlir::bufferization::CloneOp, mlir::PatternRewriter&) const BufferizationOps.cpp:0:0
#8 0x000055d8d8d0700a mlir::detail::OpOrInterfaceRewritePatternBase<mlir::bufferization::CloneOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x1af100a)
#9 0x000055d8de20b1d8 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/data/bin/llvm-project/build/bin/mlir-opt+0x6ff51d8)
#10 0x000055d8db57e9fc (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#11 0x000055d8db582e6b mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/bin/llvm-project/build/bin/mlir-opt+0x436ce6b)
#12 0x000055d8db4e813a (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#13 0x000055d8db4c908e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b308e)
#14 0x000055d8db4c956a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b356a)
#15 0x000055d8db4ca633 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (mlir::OpPassManager&, mlir::Operation*)>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::'lambda'(mlir::OpPassManager&, mlir::Operation*)>(long, mlir::OpPassManager&, mlir::Operation*) Pass.cpp:0:0
#16 0x000055d8db4f8323 (anonymous namespace)::InlinerPass::optimizeCallable(mlir::CallGraphNode*, llvm::StringMap<mlir::OpPassManager, llvm::MallocAllocator>&) Inliner.cpp:0:0
#17 0x000055d8db501256 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult ((anonymous namespace)::CallGraphSCC&)>::callback_fn<(anonymous namespace)::InlinerPass::runOnOperation()::'lambda'((anonymous namespace)::CallGraphSCC&)>(long, (anonymous namespace)::CallGraphSCC&) Inliner.cpp:0:0
#18 0x000055d8db502043 (anonymous namespace)::InlinerPass::runOnOperation() Inliner.cpp:0:0
#19 0x000055d8db4c908e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b308e)
#20 0x000055d8db4c956a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b356a)
#21 0x000055d8db4c9d94 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b3d94)
#22 0x000055d8db4bab03 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#23 0x000055d8db4bbfd4 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#24 0x000055d8db4bc184 mlir::LogicalResult llvm::function_ref<mlir::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&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#25 0x000055d8db5bb474 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/data/bin/llvm-project/build/bin/mlir-opt+0x43a5474)
#26 0x000055d8db4b49e7 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x429e9e7)
#27 0x000055d8db4bc2d1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x42a62d1)
#28 0x000055d8db4bc736 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x42a6736)
#29 0x000055d8d878e4eb main (/data/bin/llvm-project/build/bin/mlir-opt+0x15784eb)
#30 0x00007fe90953c083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#31 0x000055d8d88271ce _start (/data/bin/llvm-project/build/bin/mlir-opt+0x16111ce)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWltz27gV_jX0C8YaELw_-EGW7W1m4toTp-2jBiQOJXQhgAXArJVf3wFISSQt2cra3aaXTCJF4MGHcz8HAKkxfCUBroLkOkhuLmhr10pfUankdqNac794uigV216tuEXfQBuuZBDNERRVWkd1AhmQqCQRgxiA0jAnUNZVmTES5nlcJAG-CfC8-zRbY2HjZgcp7v7-pWylbRHBMxzPUvT56xMKSH6nKirQnTKGBqTYEw-xNDRasbYChn7jdj0C3QiuL1Vj0eUll4JLQHTmxo4C9Y-i_ueEpm5lNXMfKIix-yYByQNSoCC77igQCkhSpSiIbhDV3K5nlZLGUmmRG5wjLhk8D2nd7JfEfvQldeRpLUij9Aw2jd3uGIjm_XAQLcLwOYye64gE0e1gMhVCVcsQe4wNbDTUMz82wOiG9xg8jQcY_RwGftYE8o25AUlCTPzSZVvXoPl3armSs0ooCedhIateXcStEWedOuuaS5gJRVm_tPNor-6ALDojBcnNm3xrsK2WvTNkN0e9YvhpNa3glPvsPNG7J7lj1NKA3JVcBuROiG-by0arv0Nl-58BueOyEi2Dw8BT2zRKO4oFNZbL1cw5e5oSh8mgEnbbQEBy2lrlbOqnRfMgmrOtXFbUWBdQWm0CMvc2T65dwKCvqvOK3vmj-T1slN7e1jVU9qH5JC3o2ot2jdz0CfVDA9qbM0huHCdzY0C73y4MGVjKRUfIzaMGA9Kx8VcqPAskDUiKAkJ2LCIlEUVSyUt45saCtOgbFS0EhAQkQzXlAtis0-nj59v50y0ybbnhFlFUtiukwenIecva2sa4lcldQO5W3K7bclY56XcKneidG9OCCcgdopKhXv3IrgFVmpo1Kmn1q7dxv_yTpdWviLWbZm90PEP-z6NWK003iOpVuwFpzRlmL1su2P7hycy1c_cII_yMMcZJwnKW50kKaT2wudma7j-Pmkvref3qHZTkByJNf1sqYzXQjTfFAnFnHmeY_HexG5Br_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