Skip to content

[MLIR]-test-extract-fixed-outer-loops triggers Assertion Failure `!empty()' #116360

@xisang0

Description

@xisang0

Test on commit: 6548b63
steps to reproduce:

mlir-opt test.mlir  --test-extract-fixed-outer-loops

test case:

module {
  func.func @main(%arg0: tensor<4xi32>) -> () {
    %c4 = arith.constant 4 : index
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1 : index
    %2 = bufferization.to_memref %arg0 : memref<4xi32>
    %alloc = memref.alloc() {alignment = 64 : i64} : memref<4xi32>
    scf.for %arg4 = %c0 to %c4 step %c1 {
      %19 = memref.load %2[%arg4] : memref<4xi32>
      %20 = math.ctlz %19 : i32
      memref.store %20, %alloc[%arg4] : memref<4xi32>
    }
    return
  }
}

crash trace:

mlir-opt: /home/workdir/llvm-project-19/llvm/include/llvm/ADT/SmallVector.h:309: reference llvm::SmallVectorTemplateCommon<mlir::scf::ForOp>::back() [T = 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: ./mlir-opt /home/workdir/test.mlir --test-extract-fixed-outer-loops
^[[A #0 0x000055c40f1e53b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x10723b8)
 #1 0x000055c40f1e2ede llvm::sys::RunSignalHandlers() (./mlir-opt+0x106fede)
 #2 0x000055c40f1e5dc8 SignalHandler(int) Signals.cpp:0:0
 #3 0x000070577cebe520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000070577cf129fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000070577cebe476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000070577cea47f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000070577cea471b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000070577ceb5e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000055c41100ce2a mlir::extractFixedOuterLoops(mlir::scf::ForOp, llvm::ArrayRef<long>) (./mlir-opt+0x2e99e2a)
#10 0x000055c411ef97b5 void llvm::function_ref<void (mlir::Operation*)>::callback_fn<std::enable_if<!llvm::is_one_of<mlir::scf::ForOp, mlir::Operation*, mlir::Region*, mlir::Block*>::value && std::is_same<void, void>::value, void>::type mlir::detail::walk<(mlir::WalkOrder)1, mlir::ForwardIterator, (anonymous namespace)::SimpleParametricLoopTilingPass::runOnOperation()::'lambda'(mlir::scf::ForOp), mlir::scf::ForOp, void>(mlir::Operation*, (anonymous namespace)::SimpleParametricLoopTilingPass::runOnOperation()::'lambda'(mlir::scf::ForOp)&&)::'lambda'(mlir::Operation*)>(long, mlir::Operation*) TestLoopParametricTiling.cpp:0:0
#11 0x000055c40f2f371e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (./mlir-opt+0x118071e)
#12 0x000055c40f2f371e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (./mlir-opt+0x118071e)
#13 0x000055c411ef95dd (anonymous namespace)::SimpleParametricLoopTilingPass::runOnOperation() TestLoopParametricTiling.cpp:0:0
#14 0x000055c4124616df mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x42ee6df)
#15 0x000055c412461ec2 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x42eeec2)
#16 0x000055c41246466e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x42f166e)
#17 0x000055c41245d192 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x000055c41245cdfb 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
#19 0x000055c412506ae5 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) (./mlir-opt+0x4393ae5)
#20 0x000055c412457ff2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x42e4ff2)
#21 0x000055c4124582a3 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42e52a3)
#22 0x000055c4124584b2 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42e54b2)
#23 0x000055c40f1c45d7 main (./mlir-opt+0x10515d7)
#24 0x000070577cea5d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#25 0x000070577cea5e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#26 0x000055c40f1c4145 _start (./mlir-opt+0x1051145)
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]mlir

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions