Issue 240306
Summary [MLIR] Crash in `--test-extract-fixed-outer-loops` pass when processing unsigned `scf.for` loops
Labels mlir
Assignees
Reporter frida-albrecht
    
The `--test-extract-fixed-outer-loops` pass crashes with an assertion failure when processing an unsigned `scf.for` loop nested inside an scf.while operation.

test commit: [5fe5e53](https://github.com/llvm/llvm-project/commit/5fe5e53cff518bb81e2debaff4747c8b9bac130b)

test case:
```mlir
module {
  func.func @main(%arg0: i1) -> (i1, i1, i1, i1, i1, i1) {
    %0:6 = scf.while (%arg1 = %arg0, %arg2 = %arg0, %arg3 = %arg0, %arg4 = %arg0, %arg5 = %arg0, %arg6 = %arg0) : (i1, i1, i1, i1, i1, i1) -> (i1, i1, i1, i1, i1, i1) {
      scf.condition(%arg1) %arg1, %arg2, %arg3, %arg4, %arg5, %arg6 : i1, i1, i1, i1, i1, i1
    } do {
    ^bb0(%arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1, %arg6: i1):
      %c1 = arith.constant 1 : index
      %c1_0 = arith.constant 1 : index
 scf.for unsigned %arg7 = %c1 to %c1 step %c1_0 {
      }
      scf.yield %arg1, %arg2, %arg3, %arg4, %arg5, %arg6 : i1, i1, i1, i1, i1, i1
    }
 return %0#0, %0#1, %0#2, %0#3, %0#4, %0#5 : i1, i1, i1, i1, i1, i1
 }
}
```



Step to reproduce:
```
mlir-opt test.mlir --test-extract-fixed-outer-loops=test-outer-loop-sizes=7,4
```

Crash backtrace:
```
mlir-opt: /home/llvm-project/llvm-project-latest/mlir/lib/Dialect/SCF/Utils/Utils.cpp:1354: mlir::Loops stripmineSink(mlir::scf::ForOp, mlir::Value, llvm::ArrayRef<mlir::scf::ForOp>): Assertion `!forOp.getUnsignedCmp() && "unsigned loops are not supported"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.      Program arguments: mlir-opt test.mlir --test-extract-fixed-outer-loops=test-outer-loop-sizes=7,4
 #0 0x000055f162e7c949 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fe3949)
 #1 0x000055f162e7914c llvm::sys::RunSignalHandlers() (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fe014c)
 #2 0x000055f162e792b6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f5bf8c37520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f5bf8c8b9bc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969bc)
 #5 0x00007f5bf8c37476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f5bf8c1d7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007f5bf8c1d71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007f5bf8c2ee96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000055f169f38222 mlir::tile(llvm::ArrayRef<mlir::scf::ForOp>, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::scf::ForOp>) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x909f222)
#10 0x000055f169f382db mlir::tile(llvm::ArrayRef<mlir::scf::ForOp>, llvm::ArrayRef<mlir::Value>, mlir::scf::ForOp) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x909f2db)
#11 0x000055f169f38f91 mlir::extractFixedOuterLoops(mlir::scf::ForOp, llvm::ArrayRef<long>) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x909ff91)
#12 0x000055f162fd006f void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.0) TestLoopParametricTiling.cpp:0:0
#13 0x000055f162fcff20 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.0) TestLoopParametricTiling.cpp:0:0
#14 0x000055f162fcff20 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.0) TestLoopParametricTiling.cpp:0:0
#15 0x000055f162fcff20 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.0) TestLoopParametricTiling.cpp:0:0
#16 0x000055f162fd051f (anonymous namespace)::SimpleParametricLoopTilingPass::runOnOperation() TestLoopParametricTiling.cpp:0:0
#17 0x000055f16b6fbf49 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa862f49)
#18 0x000055f16b6fc224 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa863224)
#19 0x000055f16b6fde72 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa864e72)
#20 0x000055f16b6fee49 mlir::PassManager::run(mlir::Operation*) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa865e49)
#21 0x000055f162f46ea6 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#22 0x000055f162f4845e processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#23 0x000055f162f486a1 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, 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::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#24 0x000055f16ba2ef2d 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::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xab95f2d)
#25 0x000055f162f4239a mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#26 0x000055f162f48ce1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x20afce1)
#27 0x000055f162f48f34 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x20aff34)
#28 0x000055f162e20d8c main (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1f87d8c)
#29 0x00007f5bf8c1ed90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x00007f5bf8c1ee40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x000055f162e5c1e5 _start (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fc31e5)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to