<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64674>64674</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] --inline crashed with assertion failure "expected 'source' to have no successors"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
anonymousMCS
</td>
</tr>
</table>
<pre>
git version: 0fb3066873fdfbe28dbb6409c58a8bff7cf208c6
system: Ubuntu 20.04.6 LTS (Focal Fossa)
reproduced with: `mlir-opt --inline a.mlir`
a.mlir:
```
func.func private @func1() {
%idx0 = index.constant 1
%alloc_20 = memref.alloc(%idx0, %idx0) : memref<?x?xi32>
scf.index_switch %idx0 -> f32
default {
%cst_11 = arith.constant 1.71053568E+9 : f32
memref.alloca_scope {
%alloc_21 = memref.alloc(%idx0, %idx0) : memref<?x?xi32>
memref.copy %alloc_20, %alloc_21 : memref<?x?xi32> to memref<?x?xi32>
func.call @__mlir_math_fpowi_f16_i32() : () -> ()
}
scf.yield %cst_11 : f32
}
return
}
func.func @func2() {
memref.alloca_scope {
%idx0 = index.constant 1
func.call @func1() : () -> ()
scf.index_switch %idx0 -> memref<?x25xi64>
default {
%alloc_18 = memref.alloc(%idx0) : memref<?x25xi64>
scf.yield %alloc_18 : memref<?x25xi64>
}
}
return
}
func.func private @__mlir_math_fpowi_f16_i32() attributes {llvm.linkage = #llvm.linkage<linkonce_odr>} {
%cst = arith.constant 1.000000e+00 : f16
%c0_i32 = arith.constant 1 : i32
cf.br ^bb3(%cst, %cst, %c0_i32 : f16, f16, i32)
^bb3(%6: f16, %7: f16, %8: i32):
cf.br ^bb5(%6 : f16)
^bb5(%12: f16):
%13 = arith.shrui %8, %c0_i32 : i32
cf.br ^bb3(%12, %12, %c0_i32 : f16, f16, i32)
}
```
trace:
```
mlir-opt: /data/bin/llvm-project/mlir/lib/IR/PatternMatch.cpp:351: virtual void mlir::RewriterBase::inlineBlockBefore(mlir::Block*, mlir::Block*, mlir::Block::iterator, mlir::ValueRange): Assertion `source->hasNoSuccessors() && "expected 'source' to have no successors"' 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 0x0000557b42ca3def llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x14b0def)
#1 0x0000557b42ca1074 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f06b8f86420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f06b8a7100b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f06b8a50859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f06b8a50729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f06b8a61fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x0000557b457ab093 mlir::RewriterBase::inlineBlockBefore(mlir::Block*, mlir::Block*, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void>, false, false>, mlir::ValueRange) (/data/bin/llvm-project/build/bin/mlir-opt+0x3fb8093)
#8 0x0000557b43dd9663 AllocaScopeInliner::matchAndRewrite(mlir::memref::AllocaScopeOp, mlir::PatternRewriter&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x25e6663)
#9 0x0000557b481f3598 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/data/bin/llvm-project/build/bin/mlir-opt+0x6a00598)
#10 0x0000557b45646657 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#11 0x0000557b4564a89b mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/bin/llvm-project/build/bin/mlir-opt+0x3e5789b)
#12 0x0000557b455b8d8a (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#13 0x0000557b45599d6e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x3da6d6e)
#14 0x0000557b4559a24a 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+0x3da724a)
#15 0x0000557b4559b3db 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 0x0000557b455c8863 (anonymous namespace)::InlinerPass::optimizeCallable(mlir::CallGraphNode*, llvm::StringMap<mlir::OpPassManager, llvm::MallocAllocator>&) Inliner.cpp:0:0
#17 0x0000557b455d13b5 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 0x0000557b455d26c3 (anonymous namespace)::InlinerPass::runOnOperation() Inliner.cpp:0:0
#19 0x0000557b45599d6e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x3da6d6e)
#20 0x0000557b4559a24a 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+0x3da724a)
#21 0x0000557b4559aa51 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x3da7a51)
#22 0x0000557b4558aefb performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#23 0x0000557b4558c3b4 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 0x0000557b4558c564 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 0x0000557b45680154 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+0x3e8d154)
#26 0x0000557b45585987 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+0x3d92987)
#27 0x0000557b4558c88b mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x3d9988b)
#28 0x0000557b42bde0e3 main (/data/bin/llvm-project/build/bin/mlir-opt+0x13eb0e3)
#29 0x00007f06b8a52083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#30 0x0000557b42c7561e _start (/data/bin/llvm-project/build/bin/mlir-opt+0x148261e)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1z4yrS_jXKDRUXAglJF7lwnPi8UzU5k0rm3b1UIYFsdmTQAsok59dvgWRbOE6cTGbPzn6kEkeG5qG_6G5A1BixkpxfROlllF6d0d6ulb6gUsmnjerNzeL-rFLs6WIlLHjg2gglIzwHsKkwJCTPcMOaiqOcVRVJYFGnOc2rpsnqBsG8JhG8iuB8-DRPxvKNG_3_VS9tDxCcwWRGwOev9yBC-VLVtAVLZQyNUDEdqXmnFetrzsB3YdcOIiJw0wp9rjoLzs-FbIXkgM5cW0TgdPDYiMevrnf49V-bXtYz9wE6LR6o5SBKoPseRyiPUAGi7HKgBCBCqWCPEET4CgjJ-OOsVtJYKi2IJzS0bVVdooFuwzeaNzPf5hE9RIQWYPdYACfQQBjhRYSXj-5PYBTh6y2uqZuZn7M034Wt1ztmziN8DRqMwJaS8Yb2rZ0wHqG0NraMY88R1cKuJ5zPshimOCX5dYQuB14ajLZoIJCAlqZWHZ8qxf3shY5_ptAjTK26p6leR5zJjC8CAatOzOHtX9O2dXYvS-cq5Ybaddl06rsom5iUjn70Bed4w6NX-_C810SUXe2_OIs9Cd6yQP-Bcif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