Issue 74313
Summary [mlir] --inline crashed in mlir::RewriterBase::eraseOp with assertion failure "expected that op has no uses".
Labels mlir
Assignees
Reporter anonymousMCS
    git version: e9c6f3f5e7e23b23de4eeaa182ebfcb7d2188495

system: ```Ubuntu 20.04.6 LTS (Focal Fossa)```

reproduced with: ```mlir-opt --inline a.mlir```

a.mlir:
```
func.func private @func2() {
  %c8 = arith.constant 8 : index
  %c25 = arith.constant 25 : index
  %alloc_15 = memref.alloc(%c25) {alignment = 64 : i64} : memref<?x3xf16>
  %10 = bufferization.to_tensor %alloc_15 : memref<?x3xf16>
  %13 = memref.alloca_scope  -> (memref<27xf32>) {
    %c0_79 = arith.constant 0 : index
    %c89 = arith.constant 89 : index
    %c1_80 = arith.constant 1 : index
    %161 = scf.for %arg1 = %c0_79 to %c89 step %c1_80 iter_args(%arg2 = %10) -> (tensor<?x3xf16>) {
      %alloc_93 = memref.alloc(%c8) {alignment = 64 : i64} : memref<?x3xf16>
      %194 = bufferization.to_tensor %alloc_93 : memref<?x3xf16>
      scf.yield %194 : tensor<?x3xf16>
    }
    %172 = math.ceil %161 : tensor<?x3xf16>
 %alloc_92 = memref.alloc() : memref<27xf32>
 memref.alloca_scope.return %alloc_92 : memref<27xf32>
  }
  %115 = bufferization.clone %13 : memref<27xf32> to memref<27xf32>
 return
}
```


trace:
```
mlir-opt: /data/bin/llvm-project/mlir/lib/IR/PatternMatch.cpp:326: mlir::RewriterBase::eraseOp(mlir::Operation*)::<lambda(mlir::Operation*)>: Assertion `mayBeGraphRegion(*op->getParentRegion()) && "expected that op has no 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/bin/llvm-project/build/bin/mlir-opt --inline a.mlir
 #0 0x000056547210ae6f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x1640e6f)
 #1 0x0000565472107ec4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fdda0f6f420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007fdda0a5a00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007fdda0a39859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007fdda0a39729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007fdda0a4afd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x0000565474f9ce7e mlir::RewriterBase::eraseOp(mlir::Operation*)::'lambda0'(mlir::Operation*)::operator()(mlir::Operation*) const (.isra.0) PatternMatch.cpp:0:0
 #8 0x0000565474f9c676 mlir::RewriterBase::eraseOp(mlir::Operation*)::'lambda0'(mlir::Operation*)::operator()(mlir::Operation*) const (.isra.0) PatternMatch.cpp:0:0
 #9 0x0000565474f9d156 mlir::RewriterBase::eraseOp(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x44d3156)
#10 0x0000565474e32a77 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#11 0x0000565474e36e6b mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/bin/llvm-project/build/bin/mlir-opt+0x436ce6b)
#12 0x0000565474d9c13a (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#13 0x0000565474d7d08e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b308e)
#14 0x0000565474d7d56a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b356a)
#15 0x0000565474d7e633 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (mlir::OpPassManager&, mlir::Operation*)>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::'lambda'(mlir::OpPassManager&, mlir::Operation*)>(long, mlir::OpPassManager&, mlir::Operation*) Pass.cpp:0:0
#16 0x0000565474dac323 (anonymous namespace)::InlinerPass::optimizeCallable(mlir::CallGraphNode*, llvm::StringMap<mlir::OpPassManager, llvm::MallocAllocator>&) Inliner.cpp:0:0
#17 0x0000565474db5256 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult ((anonymous namespace)::CallGraphSCC&)>::callback_fn<(anonymous namespace)::InlinerPass::runOnOperation()::'lambda'((anonymous namespace)::CallGraphSCC&)>(long, (anonymous namespace)::CallGraphSCC&) Inliner.cpp:0:0
#18 0x0000565474db6043 (anonymous namespace)::InlinerPass::runOnOperation() Inliner.cpp:0:0
#19 0x0000565474d7d08e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b308e)
#20 0x0000565474d7d56a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b356a)
#21 0x0000565474d7dd94 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b3d94)
#22 0x0000565474d6eb03 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#23 0x0000565474d6ffd4 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
#24 0x0000565474d70184 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
#25 0x0000565474e6f474 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) (/data/bin/llvm-project/build/bin/mlir-opt+0x43a5474)
#26 0x0000565474d689e7 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x429e9e7)
#27 0x0000565474d702d1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x42a62d1)
#28 0x0000565474d70736 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x42a6736)
#29 0x00005654720424eb main (/data/bin/llvm-project/build/bin/mlir-opt+0x15784eb)
#30 0x00007fdda0a3b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#31 0x00005654720db1ce _start (/data/bin/llvm-project/build/bin/mlir-opt+0x16111ce)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to