<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118224>118224</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] Crash when using --test-loop-fusion=test-loop-fusion-transformation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wangyongj1a
</td>
</tr>
</table>
<pre>
I have the following MLIR program:
test.mlir:
```
module {
func.func @func1() {
%cst_18 = arith.constant 1.684800e+04 : f16
%alloc_28 = memref.alloc() : memref<6x6xf16>
%c0 = arith.constant 0 : index
%1 = affine.for %arg0 = 0 to 108 step 4 iter_args(%arg1 = %c0) -> (index) {
affine.store %cst_18, %alloc_28[0, 0] : memref<6x6xf16>
affine.yield %arg1 : index
}
%2 = affine.for %arg0 = 108 to 110 iter_args(%arg1 = %c0) -> (index) {
affine.store %cst_18, %alloc_28[0, 0] : memref<6x6xf16>
affine.yield %arg1 : index
}
vector.print %2 : index
return
}
}
```
The above MLIR program will cause a crash when using the following command:
```
mlir-opt --test-loop-fusion=test-loop-fusion-transformation test.mlir
```
And the crash backtrace is:
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /data/tmp/v1201/llvm-project/build/bin/mlir-opt --test-loop-fusion=test-loop-fusion-transformation test.mlir
#0 0x0000561410a4be6f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x150ae6f)
#1 0x0000561410a49624 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f755bf91420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x0000561412c37a94 mlir::vector::PrintOp::verifyInvariantsImpl() (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x36f6a94)
#4 0x0000561412c37d04 mlir::Op<mlir::vector::PrintOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::ZeroResults, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::VariadicOperands, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::MemoryEffectOpInterface::Trait>::verifyInvariants(mlir::Operation*) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x36f6d04)
#5 0x0000561412bd217c mlir::RegisteredOperationName::Model<mlir::vector::PrintOp>::verifyInvariants(mlir::Operation*) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x369117c)
#6 0x0000561413ae4e92 (anonymous namespace)::OperationVerifier::verifyOnEntrance(mlir::Operation&) (.isra.0) Verifier.cpp:0:0
#7 0x0000561413ae5975 (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#8 0x0000561413ae746a mlir::verify(mlir::Operation*, bool) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x45a646a)
#9 0x00005614138c6203 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x4385203)
#10 0x00005614138c6451 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x4385451)
#11 0x00005614138c4f16 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x4383f16)
#12 0x00005614138c5959 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x4384959)
#13 0x00005614138c6451 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x4385451)
#14 0x00005614138c74f6 mlir::PassManager::run(mlir::Operation*) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x43864f6)
#15 0x00005614138b7973 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#16 0x00005614138b86af processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#17 0x00005614138b87f4 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&)::'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
#18 0x00005614139baae5 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/tmp/v1201/llvm-project/build/bin/mlir-opt+0x4479ae5)
#19 0x00005614138b0de9 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x436fde9)
#20 0x00005614138b8961 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x4377961)
#21 0x00005614138b8e26 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x4377e26)
#22 0x0000561410984a7b main (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x1443a7b)
#23 0x00007f755ba3f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#24 0x0000561410a2035e _start (/data/tmp/v1201/llvm-project/build/bin/mlir-opt+0x14df35e)
Segmentation fault (core dumped)
```
My git version is 22417ec6cca0ed8ccecb0c2b77011e591378fd2a.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWV1z4ygW_TXkhYoLgT4f8uB81aZqsklNuuZhX1wIXcnMYNACSsf_fgvJjmR14nT3eLtnp7aq247FhXvOgQv3Cu6cbDTABUouUXJ9xju_NvbiM9fN1ujm94iflabaXtzhNX8G7NeAa6OU-Sx1g-9_ufsVt9Y0lm8QWyKy9OD8YqOkHX6ilOz-keXGVJ0CjLJLRJYY150Wi_CBUUzCd4RojmjxaoAxoolwfhXlGLFrzK3064Uw2nmuPY4WaR7nhACilyTGiC1xHaVjT66UESs69N3AxkK96J_t3bDl7jFiV-lL-hJ6s5uJa_KWW9J3lLqCl9E0GizrWmpY1Mb2_m0zDECwNzgiOXYeWhxj6cGuuG1cDyTYDd17lwHZOWI3GNF8cDIqshvfeWNh1AbRqyldlFyS8Iig5PoDjng_4laCqvCIZcYvux6Z0mNMA8nANSLfT3KK6ycyJUv8DMIbu2it1H5P_dDegu-s7n8MXXefk0X_aQ2Yl-YZDmIFf5ZKYcE7B5hjYblb489r0Lhz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