[Mlir-commits] [mlir] [mlir][Interfaces] Fix use-after-free after #176641 (PR #177536)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Jan 22 23:14:12 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Matthias Springer (matthias-springer)

<details>
<summary>Changes</summary>

Fix a use-after-free after #<!-- -->176641: the successor operands `OperandRange` is now longer value after the terminator has been erased.


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


1 Files Affected:

- (modified) mlir/lib/Interfaces/ControlFlowInterfaces.cpp (+4-4) 


``````````diff
diff --git a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
index 8ed32ddf39a53..09eccc30b2469 100644
--- a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
+++ b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
@@ -1182,8 +1182,8 @@ struct InlineRegionBranchOp : public RewritePattern {
     // Inline all regions on the path into the enclosing block.
     rewriter.setInsertionPoint(op);
     ArrayRef remainingPath = path;
-    OperandRange successorOperands =
-        regionBranchOp.getEntrySuccessorOperands(remainingPath.front());
+    SmallVector<Value> successorOperands =
+        llvm::to_vector(regionBranchOp.getEntrySuccessorOperands(remainingPath.front()));
     while (!remainingPath.empty()) {
       RegionSuccessor nextSuccessor = remainingPath.consume_front();
       ValueRange successorInputs =
@@ -1239,8 +1239,8 @@ struct InlineRegionBranchOp : public RewritePattern {
       rewriter.inlineBlockBefore(&nextSuccessor.getSuccessor()->front(),
                                  op->getBlock(), op->getIterator(),
                                  replacements);
-      successorOperands =
-          terminator.getSuccessorOperands(remainingPath.front());
+      successorOperands = llvm::to_vector(
+          terminator.getSuccessorOperands(remainingPath.front()));
       rewriter.eraseOp(terminator);
     }
 

``````````

</details>


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


More information about the Mlir-commits mailing list