[Mlir-commits] [mlir] [mlir][Inliner] Fix crash when inlining callee without terminator (PR #173665)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Dec 26 06:24:42 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Suriyaa MM (SuriyaaMM)

<details>
<summary>Changes</summary>

Fix for [#<!-- -->173561](https://github.com/llvm/llvm-project/issues/173561).

`call.erase()` would `segfault` previously if not all uses are replaced. 

---
Full diff: https://github.com/llvm/llvm-project/pull/173665.diff


1 Files Affected:

- (modified) mlir/lib/Transforms/Utils/Inliner.cpp (+8-1) 


``````````diff
diff --git a/mlir/lib/Transforms/Utils/Inliner.cpp b/mlir/lib/Transforms/Utils/Inliner.cpp
index 40950312d566f..b3a0994f2070a 100644
--- a/mlir/lib/Transforms/Utils/Inliner.cpp
+++ b/mlir/lib/Transforms/Utils/Inliner.cpp
@@ -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");
+      return failure();
+    }
 
     // If we inlined in place, mark the node for deletion.
     if (inlineInPlace) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/173665


More information about the Mlir-commits mailing list