[PATCH] D74583: Fix Block::eraseArgument when block arg is also a successor operand.
Sean Silva via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 13 16:31:12 PST 2020
silvas created this revision.
silvas added a reviewer: rriddle.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, mehdi_amini.
Herald added 1 blocking reviewer(s): rriddle.
Herald added a project: LLVM.
This could trigger an assertion due to the block argument being used by
this block's own successor operands.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74583
Files:
mlir/lib/IR/Block.cpp
Index: mlir/lib/IR/Block.cpp
===================================================================
--- mlir/lib/IR/Block.cpp
+++ mlir/lib/IR/Block.cpp
@@ -170,20 +170,21 @@
void Block::eraseArgument(unsigned index, bool updatePredTerms) {
assert(index < arguments.size());
+ // If requested, update predecessors. We do this first since this block might
+ // be a predecessor of itself and use this block argument as a successor
+ // operand.
+ if (updatePredTerms) {
+ // Erase this argument from each of the predecessor's terminator.
+ for (auto predIt = pred_begin(), predE = pred_end(); predIt != predE;
+ ++predIt) {
+ auto *predTerminator = (*predIt)->getTerminator();
+ predTerminator->eraseSuccessorOperand(predIt.getSuccessorIndex(), index);
+ }
+ }
+
// Delete the argument.
arguments[index].destroy();
arguments.erase(arguments.begin() + index);
-
- // If we aren't updating predecessors, there is nothing left to do.
- if (!updatePredTerms)
- return;
-
- // Erase this argument from each of the predecessor's terminator.
- for (auto predIt = pred_begin(), predE = pred_end(); predIt != predE;
- ++predIt) {
- auto *predTerminator = (*predIt)->getTerminator();
- predTerminator->eraseSuccessorOperand(predIt.getSuccessorIndex(), index);
- }
}
/// Insert one value to the given position of the argument list. The existing
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74583.244549.patch
Type: text/x-patch
Size: 1400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200214/4a1ed5e0/attachment.bin>
More information about the llvm-commits
mailing list