Issue 128311
Summary [MLIR]`-test-ir-visitors` triggers Assertion Failure `use_empty() && "Cannot destroy a value that still has uses!"'
Labels mlir
Assignees
Reporter xisang0
    Test on commit: https://github.com/llvm/llvm-project/commit/a9882bda96228ca23e166a817f93a7dbc99763cb
steps to reproduce:
```
mlir-opt test.mlir -test-ir-visitors
```
test case:
```
module {
  func.func @ifElseNested(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
    %0 = memref.alloc() : memref<2xf32>
    test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>)
    cf.cond_br %arg0,
      ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>),
      ^bb2(%0, %arg1 : memref<2xf32>, memref<2xf32>)
 ^bb1(%1: memref<2xf32>, %2: memref<2xf32>):
    cf.br ^bb5(%1, %2 : memref<2xf32>, memref<2xf32>)
  ^bb2(%3: memref<2xf32>, %4: memref<2xf32>):
    cf.cond_br %arg0, ^bb3(%3 : memref<2xf32>), ^bb4(%4 : memref<2xf32>)
  ^bb3(%5: memref<2xf32>):
    cf.br ^bb5(%5, %3 : memref<2xf32>, memref<2xf32>)
  ^bb4(%6: memref<2xf32>):
    cf.br ^bb5(%3, %6 : memref<2xf32>, memref<2xf32>)
  ^bb5(%7: memref<2xf32>, %8: memref<2xf32>):
    %9 = memref.alloc() : memref<2xf32>
 test.buffer_based in(%7: memref<2xf32>) out(%9: memref<2xf32>)
 test.copy(%9, %arg2) : (memref<2xf32>, memref<2xf32>)
    return
 }
}
```
crash trace:
```
mlir-opt: /home/workdir/llvm-project-19/mlir/include/mlir/IR/UseDefLists.h:198: mlir::IRObjectWithUseList<mlir::OpOperand>::~IRObjectWithUseList() [OperandType = mlir::OpOperand]: 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: ./mlir-opt /home/workdir/test.mlir -test-ir-visitors
 #0 0x000058b679ff0998 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x108a998)
 #1 0x000058b679fee4be llvm::sys::RunSignalHandlers() (./mlir-opt+0x10884be)
 #2 0x000058b679ff13a8 SignalHandler(int) Signals.cpp:0:0
 #3 0x000078a239f02520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000078a239f569fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000078a239f02476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000078a239ee87f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000078a239ee871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000078a239ef9e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000058b67d3a0277 mlir::Block::~Block() (./mlir-opt+0x443a277)
#10 0x000058b67d3a069d mlir::Block::erase() (./mlir-opt+0x443a69d)
#11 0x000058b67c95db2e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Block*)>, mlir::WalkOrder) (./mlir-opt+0x39f7b2e)
#12 0x000058b67c95db13 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Block*)>, mlir::WalkOrder) (./mlir-opt+0x39f7b13)
#13 0x000058b67d1ad0c9 (anonymous namespace)::TestIRVisitorsPass::runOnOperation() TestVisitors.cpp:0:0
#14 0x000058b67d2c13bf mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x435b3bf)
#15 0x000058b67d2c1ba2 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x435bba2)
#16 0x000058b67d2c434e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x435e34e)
#17 0x000058b67d2bce6b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x000058b67d2bcacb 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 0x000058b67d365df5 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+0x43ffdf5)
#20 0x000058b67d2b79b2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x43519b2)
#21 0x000058b67d2b7c63 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4351c63)
#22 0x000058b67d2b7e72 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4351e72)
#23 0x000058b679fcfc27 main (./mlir-opt+0x1069c27)
#24 0x000078a239ee9d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#25 0x000078a239ee9e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#26 0x000058b679fcf795 _start (./mlir-opt+0x1069795)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to