Skip to content

[mlir] -lift-cf-to-scf crashes #120883

@Anonymous7i0em3yd

Description

@Anonymous7i0em3yd

git version: bc29fc9

system: Ubuntu 18.04.6 LTS

reproduce with: mlir-opt -lift-cf-to-scf a.mlir

a.mlir:

module {
  func.func private @ext_func_result_attrs(%arg0: f32) -> (i32, i32) {
    %cst0_i32 = spirv.Constant 0 : i32
    %cst-1_i32 = spirv.Constant -1 : i32
    %0 = spirv.Variable :!spirv.ptr<i32, Function>
    %1 = spirv.Variable :!spirv.ptr<i32, Function>
    spirv.mlir.loop {
      spirv.Branch ^bb1(%cst0_i32, %cst-1_i32 : i32, i32)
    ^bb1(%3: i32, %4: i32):  // 2 preds: ^bb0, ^bb2
      %5 = spirv.SLessThan %3, %cst-1_i32 : i32
      spirv.BranchConditional %5, ^bb2, ^bb3
    ^bb2:  // pred: ^bb1
      %6 = spirv.IAdd %3, %4 : i32
      spirv.Store "Function" %0, %6 : i32
      %7 = spirv.IAdd %3, %cst0_i32 : i32
      spirv.Branch ^bb1(%7, %6 : i32, i32)
    ^bb3:  // pred: ^bb1
      spirv.mlir.merge
    }
    %2 = spirv.Load "Function" %1 : i32
    %3 = spirv.Load "Function" %0 : i32
    return %3, %2 : i32, i32
  }
}

stack trace:

/data/szy/MLIR/seed/seed29/tmp.1nu1IKGsQn.mlir:11:7: error: 'spirv.BranchConditional' op Cannot convert unknown control flow op to structured control flow
      spirv.BranchConditional %5, ^bb2, ^bb3
      ^
/data/szy/MLIR/seed/seed29/tmp.1nu1IKGsQn.mlir:11:7: note: see current operation: "spirv.BranchConditional"(%10, %6, %6, %7, %8)[INVALIDBLOCK, ^bb1] <{operandSegmentSizes = array<i32: 1, 0, 4>}> : (i1, i32, i32, i32, i32) -> ()
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/include/mlir/IR/UseDefLists.h:198: mlir::IRObjectWithUseList<mlir::BlockOperand>::~IRObjectWithUseList() [OperandType = mlir::BlockOperand]: Assertion `use_empty() && "Cannot destroy a value that still has uses!"' failed.
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 -lift-cf-to-scf /data/szy/MLIR/seed/seed29/tmp.1nu1IKGsQn.mlir
 #0 0x000056551cfda418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ee418)
 #1 0x000056551cfd7f2e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ebf2e)
 #2 0x000056551cfdadad SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f25fa8ce420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f25f9f0b00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f25f9eea859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f25f9eea729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f25f9eea729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f25f9efbfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x000056552001baf9 (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x422faf9)
#10 0x00005655200f65e6 llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block>>::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, true, false, void, false, void>, false, false>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x430a5e6)
#11 0x00005655200f4fab mlir::Region::~Region() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4308fab)
#12 0x000056551ff89278 mlir::transformCFGToSCF(mlir::Region&, mlir::CFGToSCFInterface&, mlir::DominanceInfo&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x419d278)
#13 0x000056551fa8b20f mlir::WalkResult llvm::function_ref<mlir::WalkResult (mlir::Operation*)>::callback_fn<(anonymous namespace)::LiftControlFlowToSCF::runOnOperation()::'lambda'(mlir::func::FuncOp)::operator()(mlir::func::FuncOp) const::'lambda'(mlir::Operation*)>(long, mlir::Operation*) ControlFlowToSCF.cpp:0:0
#14 0x000056551d107e27 mlir::WalkResult mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<mlir::WalkResult (mlir::Operation*)>, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x131be27)
#15 0x000056551fa8adfe mlir::WalkResult llvm::function_ref<mlir::WalkResult (mlir::Operation*)>::callback_fn<std::enable_if<!llvm::is_one_of<mlir::func::FuncOp, mlir::Operation*, mlir::Region*, mlir::Block*>::value && std::is_same<mlir::WalkResult, mlir::WalkResult>::value, mlir::WalkResult>::type mlir::detail::walk<(mlir::WalkOrder)1, mlir::ForwardIterator, (anonymous namespace)::LiftControlFlowToSCF::runOnOperation()::'lambda'(mlir::func::FuncOp), mlir::func::FuncOp, mlir::WalkResult>(mlir::Operation*, (anonymous namespace)::LiftControlFlowToSCF::runOnOperation()::'lambda'(mlir::func::FuncOp)&&)::'lambda'(mlir::Operation*)>(long, mlir::Operation*) ControlFlowToSCF.cpp:0:0
#16 0x000056551d107e27 mlir::WalkResult mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<mlir::WalkResult (mlir::Operation*)>, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x131be27)
#17 0x000056551fa8ab97 (anonymous namespace)::LiftControlFlowToSCF::runOnOperation() ControlFlowToSCF.cpp:0:0
#18 0x000056551ff3ad66 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414ed66)
#19 0x000056551ff3b690 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+0x414f690)
#20 0x000056551ff3dc62 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4151c62)
#21 0x000056551ff363da performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#22 0x000056551ff3602d 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
#23 0x000056551ffe1985 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+0x41f5985)
#24 0x000056551ff30015 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+0x4144015)
#25 0x000056551ff302bf mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41442bf)
#26 0x000056551ff305ee mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41445ee)
#27 0x000056551cfbaf07 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cef07)
#28 0x00007f25f9eec083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#29 0x000056551cfbaa7e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cea7e)

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