Skip to content

Commit 070632a

Browse files
committed
[ShrinkBorrowScope] Added assertion.
Checked that a barrier terminator's successor isn't a merge point.
1 parent 8bb465a commit 070632a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/SILOptimizer/Utils/ShrinkBorrowScope.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,15 @@ bool Rewriter::run() {
383383
if (auto *terminator = dyn_cast<TermInst>(instruction)) {
384384
auto successors = terminator->getParentBlock()->getSuccessorBlocks();
385385
for (auto *successor : successors) {
386+
// If a terminator is a barrier, it must not branch to a merge point.
387+
// Doing so would require one of the following:
388+
// - the terminator was passed a phi--which is handled by barriers.phis
389+
// - the terminator had a result--which can't happen thanks to the lack
390+
// of critical edges
391+
// - the terminator was a BranchInst which was passed no arguments but
392+
// which was nonetheless identified as a barrier--which is illegal
393+
assert(successor->getSinglePredecessorBlock() ==
394+
terminator->getParentBlock());
386395
madeChange |= createEndBorrow(&successor->front());
387396
}
388397
} else {

0 commit comments

Comments
 (0)