[Mlir-commits] [mlir] [mlir][Interfaces] Fix use-after-free after #176641 (PR #177536)
Matthias Springer
llvmlistbot at llvm.org
Thu Jan 22 23:13:39 PST 2026
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/177536
Fix a use-after-free after #176641: the successor operands `OperandRange` is now longer value after the terminator has been erased.
>From e59ef719cf8b7f88a167ddfca343f5a980e77c8d Mon Sep 17 00:00:00 2001
From: Matthias Springer <me at m-sp.org>
Date: Fri, 23 Jan 2026 07:12:11 +0000
Subject: [PATCH] [mlir][Interfaces] Fix use-after-free after #176641
---
mlir/lib/Interfaces/ControlFlowInterfaces.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
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);
}
More information about the Mlir-commits
mailing list