[Mlir-commits] [mlir] [mlir][Inliner] Fix crash when inlining callee without terminator (PR #173665)
Suriyaa MM
llvmlistbot at llvm.org
Sat Dec 27 01:05:59 PST 2025
================
@@ -682,7 +682,14 @@ Inliner::Impl::inlineCallsInSCC(InlinerInterfaceImpl &inlinerIface,
useList.mergeUsesAfterInlining(it.targetNode, it.sourceNode);
// then erase the call.
- call.erase();
+ if (call.getOperation()->use_empty()) {
+ call.erase();
+ } else {
+ LDBG() << "CallOpInterface is still in use. call = " << call
+ << " returning failure";
+ call->emitError("not all uses of call were replaced");
----------------
SuriyaaMM wrote:
Not 100% sure, but based on the IR, it looks like it is not returning anything and `replaceAllUsesWith` isn't getting called and `call.erase()` is still pointing to something. I think the IR is invalid, so instead of segfault, we're returning error?
IR Used
```llvm
module {
llvm.func @gen_broadcast_scalar1d(%arg0: i32) -> i32 attributes {llvm.emit_c_interface} {
%0 = "test.broadcast_bounds_mismatch1"(%arg0) : (i32) -> i32
}
llvm.func @_mlir_ciface_gen_broadcast_scalar1d(%arg0: i32) -> i32 attributes {llvm.emit_c_interface} {
%0 = llvm.call @gen_broadcast_scalar1d(%arg0) : (i32) -> i32
llvm.return %0 : i32
}
}
```
https://github.com/llvm/llvm-project/pull/173665
More information about the Mlir-commits
mailing list