<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/108364>108364</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] -buffer-loop-hoisting crashes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
axeabc
</td>
</tr>
</table>
<pre>
git version: 8168088f0a9015b
system: `Ubuntu 18.04.6 LTS`
reproduce with: `mlir-opt -buffer-loop-hoisting a.mlir`
a.mlir:
```
module attributes {llvm.data_layout = ""} {
func.func @nested(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
cf.cond_br %arg0, ^bb1, ^bb2
^bb1: // pred:^bb0
cf.br ^bb2
^bb2: // 2 predecessors, ^bb0 and ^bb1, 2 successors: ^bb3, ^bb4
cf.br ^bb2
^bb3: // pred:^bb2
%alloc = memref.alloc() : memref<2xf32>
memref.dealloc %alloc : memref<2xf32>
cf.br ^bb2
^bb4: // pred:^bb2
%alloc_0 = memref.alloc() : memref<2xf32>
memref.dealloc %alloc_0 : memref<2xf32>
cf.br ^bb2
}
}
```
stack trace:
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -buffer-loop-hoisting a.mlir
#0 0x00005555caadf2c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10dc2c8)
#1 0x00005555caadcdde llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d9dde)
#2 0x00005555caadfc5d SignalHandler(int) Signals.cpp:0:0
#3 0x00007f8f48608420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00005555cb02281f mlir::bufferization::hoistBuffersFromLoops(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x161f81f)
#5 0x00005555cdc06156 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4203156)
#6 0x00005555cdc06ac0 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4203ac0)
#7 0x00005555cdc0be7e mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#8 0x00005555cdc0819b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x420519b)
#9 0x00005555cdc062a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42032a8)
#10 0x00005555cdc06ac0 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4203ac0)
#11 0x00005555cdc09102 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4206102)
#12 0x00005555cdc01931 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#13 0x00005555cdc0158b 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
#14 0x00005555cdcadf25 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) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42aaf25)
#15 0x00005555cdbfc9b5 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f99b5)
#16 0x00005555cdbfcc5f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9c5f)
#17 0x00005555cdbfcf8e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9f8e)
#18 0x00005555caabff07 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bcf07)
#19 0x00007f8f47c26083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#20 0x00005555caabfa8e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bca8e)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWd9v4yoW_mvIC6qFwXbshzxk2kY7UqtW7exzhAE77CXgBTy3vX_9CttJbLeZuV01d7Q_pDax4ZzD933ngDGhzslaC7EC6ReQ3ixo63fGruiLoCVblIa_rmrp4XdhnTQakDXM4yxHeV4hWqA4LQG6AWjdf7pX58U-GIEM_b1stW9hnEcoiTJ49-0ZZGhsbUVjDW-ZgL9Lvxu89kraK9N4eFW2VSXslTKmudoZ6bzUNaRRMJgFGhrJcBt6uz_Y3-8Nb5WA1Hsry9YLB8Hyi1Lf9xGnnm4VfTWth4DcQIBx-FveBIveGcKq1SwKHxAkSAvnBQc4BziltkYBtYwBvoZ9Qxwa9mJvRQXINX6pCAbk9tSPz_QXoxFZFTGj-ba08DBK8E9vyzI-XuEDvKGdhEu8AXgDGyt4ECN0oIMZDGFDxLHzcDPyxZ23YMI5Y91xNASp5iMIGLqWHYzIEIgczZMTk_mQB9MzePEJb-CulGFdZnrJoq6hU7-A7yt5dB88uBiCnKL90O0s5OQDkLfoc0F38T4Oe3kzTIjjxWxmOE_Zb9BbysRp9rxr-Xh3u36-ha4t99JDCsu2hlY0xnroDdx534Q66NWppd-1ZcTMHuBNmGfD11VjzT8E8wBvpHOtcEHJUFdSM9VyAf1OQGap28GSst86WFE__HMHlLf75ogTRRA-WlNbuofU1u1eaN_XIt6EeQ3wxv3xCvDm_u7r0wGBFUpQJ94CKlupePiWGuDNn1uEhjmECYLoBSGE0jRNGaW8wiyHHXGyBiSsiv3Fo5Xad1S-dZLj_GRk6e9b47wVdA9wFmaS1L6rmFA4n8YI4C_oJUacYRbq8cQhnnFgnIv3ODy1-lnWmqq_Uc2VCGtEfjmYBediAhPPpWYphxNAAOeDcn2zi1gTqgZ1_8dAZAi0rPIqyTOUJxjB7dYK540VW-sHRkqWAG9e8mybJVdK6vblqtZt39H4nRWUR85EqEecJ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