Skip to content

Commit 59cb243

Browse files
committed
Add a new utility to mark a new block as reachable in DeadEndBlocks
1 parent e9df268 commit 59cb243

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

include/swift/SIL/BasicBlockUtils.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ class DeadEndBlocks {
9191
/// the set of reachable blocks.
9292
void updateForReachableBlock(SILBasicBlock *reachableBB);
9393

94+
/// Add new blocks to the set of reachable blocks.
95+
void updateForNewBlock(SILBasicBlock *newBB);
96+
9497
const SILFunction *getFunction() const { return f; }
95-
98+
9699
/// Performs a simple check if \p block (or its single successor) ends in an
97100
/// "unreachable".
98101
///

lib/SIL/Utils/BasicBlockUtils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,16 @@ void DeadEndBlocks::updateForReachableBlock(SILBasicBlock *reachableBB) {
404404
propagateNewlyReachableBlocks(numReachable);
405405
}
406406

407+
void DeadEndBlocks::updateForNewBlock(SILBasicBlock *newBB) {
408+
if (!didComputeValue)
409+
return;
410+
411+
assert(reachableBlocks.count(newBB) == 0);
412+
unsigned numReachable = reachableBlocks.size();
413+
reachableBlocks.insert(newBB);
414+
propagateNewlyReachableBlocks(numReachable);
415+
}
416+
407417
bool DeadEndBlocks::triviallyEndsInUnreachable(SILBasicBlock *block) {
408418
// Handle the case where a single "unreachable" block (e.g. containing a call
409419
// to fatalError()), is jumped to from multiple source blocks.

0 commit comments

Comments
 (0)