<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61716>61716</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]`test-extract-fixed-outer-loops` pass with no option leads to Assertion Failure '!empty()'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
BealZephyr
</td>
</tr>
</table>
<pre>
I think a default value of `test-outer-loop-sizes` should be set to avoid this crash.
Test commit: https://github.com/llvm/llvm-project/commit/938deaad8ac92d9a45db8ef2d8a71fbf04958d90
steps to reproduce:
```
mlir-opt test.mlir -test-extract-fixed-outer-loops
```
test case:
```
func.func @rectangular(%arg0: memref<?x?xf32>) {
%c2 = arith.constant 2 : index
%c44 = arith.constant 44 : index
%c1 = arith.constant 1 : index
scf.for %arg1 = %c2 to %c44 step %c1 {
scf.for %arg2 = %c1 to %c44 step %c2 {
%0 = memref.load %arg0[%arg1, %arg2] : memref<?x?xf32>
}
}
return
}
```
crash trace:
```
mlir-opt: /home/ty/llvm-project/llvm/include/llvm/ADT/SmallVector.h:312: T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::back() [with T = mlir::scf::ForOp; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::reference = mlir::scf::ForOp&]: Assertion `!empty()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/ty/llvm-project/build/bin/mlir-opt test.mlir -test-extract-fixed-outer-loops
#0 0x0000563a9a8452fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/ty/llvm-project/build/bin/mlir-opt+0x2282fa)
#1 0x0000563a9a84258c SignalHandler(int) Signals.cpp:0:0
#2 0x00007fe71745d980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#3 0x00007fe71610ee87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#4 0x00007fe7161107f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
#5 0x00007fe7161003fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
#6 0x00007fe716100472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
#7 0x0000563a9b3dc817 mlir::extractFixedOuterLoops(mlir::scf::ForOp, llvm::ArrayRef<long>) (/home/ty/llvm-project/build/bin/mlir-opt+0xdbf817)
#8 0x0000563a9bdba764 _ZN4llvm12function_refIFvPN4mlir9OperationEEE11callback_fnIZNS1_6detail4walkILNS1_9WalkOrderE1ENS1_15ForwardIteratorEZN12_GLOBAL__N_130SimpleParametricLoopTilingPass14runOnOperationEvEUlNS1_3scf5ForOpEE_SE_vEENSt9enable_ifIXaantsrSt11disjunctionIJSt7is_sameIT2_S3_ESI_ISJ_PNS1_6RegionEESI_ISJ_PNS1_5BlockEEEE5valuesrSI_IT3_vE5valueESS_E4typeES3_OT1_EUlS3_E_EEvlS3_ TestLoopParametricTiling.cpp:0:0
#9 0x0000563a9bdba549 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.191) TestLoopParametricTiling.cpp:0:0
#10 0x0000563a9bdba8e5 (anonymous namespace)::SimpleParametricLoopTilingPass::runOnOperation() TestLoopParametricTiling.cpp:0:0
#11 0x0000563a9c13e08e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b2108e)
#12 0x0000563a9c13eee3 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.constprop.510) Pass.cpp:0:0
#13 0x0000563a9c13f56d mlir::PassManager::run(mlir::Operation*) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b2256d)
#14 0x0000563a9c1334e3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#15 0x0000563a9c133bb1 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
#16 0x0000563a9c133da1 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
#17 0x0000563a9c2006f0 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) (/home/ty/llvm-project/build/bin/mlir-opt+0x1be36f0)
#18 0x0000563a9c12eec3 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b11ec3)
#19 0x0000563a9c1316ee mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b146ee)
#20 0x0000563a9a8112f0 main (/home/ty/llvm-project/build/bin/mlir-opt+0x1f42f0)
#21 0x00007fe7160f1c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#22 0x0000563a9a82414a _start (/home/ty/llvm-project/build/bin/mlir-opt+0x20714a)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWVtz27gV_jXwC8YaArw_-EGWqVY7TuyJtNtOXjggeShhAxIsADp2f30HIC1TjJw4m8x22xlbJHE5l-9ccHjItOb7FuAKhdcovLlgvTlIdXUNTHyE7vCkLgpZPV1tsDnw9hNmuIKa9cLgByZ6wLLGKPIMaHMpewPqUkjZXWr-b9Ao8rA-yF5UuACswWAjMXuQvLK0NC4V04cF8m6Qtxx-d6ANLmXTcIP8JT4Y02nkLxFdI7rec3Poi0UpG0TXQjw8Xy47JX-H0iC6HrfSdeonFTBWJaxMaZWyIKyKBGpaJSwmdVF7QRomVepNmWsDnbYiKuiUrPoSLOvJAhR54597bARXl7Iz2Cq_sE_40uEAj0ax0lzW_BGqCSr6LBnjdGb6G9xw3bflwv5gFHgKSsPafS-YQjRBNGRq71nIGmgU1MhfIX_9aP9rnyI_QzTFKL4eSWGMEQ1LipF_g5ni5rAoZasNaw22g0vM2woeT1cHwbnlbvTsenJuOTm3Wpf1opYKD2oM-wb5jHxmbY3zTHaqx3w3Pe4m53bT-W4nq-c2DdAthGQVfkY0vB6FQnT1zAGFN_hrUE-oo_hmAsr0QYHpVTs-H2dmNncBgq0zTZzjvBNagRBdH2QDiK7N05exMUYMb0vRV_AysLzZIbreNkyI36A0Ui0OyF_6hFqSO0Qj7Bb6S-QvJ6t20HSCGVjJppEt8lc7B5G_MuPEZccUa8A6P7m0wGALjiNTsPKTc9sUo_D6MzcHvBtMILgaluiyHm7WUt11yL_-Fuk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