Skip to content

Commit add0c5a

Browse files
committed
[NFC] ReachableBlocks: Add isReachable method.
Mark visit and isVisited private, these needn't be part of the interface for any current clients.
1 parent 058f9c4 commit add0c5a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

include/swift/SILOptimizer/Utils/BasicBlockOptUtils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class ReachableBlocks {
4747
/// Populate `visited` with the blocks reachable in the function.
4848
void compute();
4949

50+
/// Whether `block` is reachable from the entry block.
51+
bool isReachable(SILBasicBlock *block) const {
52+
assert(isComputed);
53+
return isVisited(block);
54+
}
55+
56+
private:
5057
/// Invoke \p visitor for each reachable block in \p f in worklist order (at
5158
/// least one predecessor has been visited--defs are always visited before
5259
/// uses except for phi-type block args). The \p visitor takes a block

lib/SILOptimizer/Utils/BasicBlockOptUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ bool swift::removeUnreachableBlocks(SILFunction &f) {
7070
bool changed = false;
7171
for (auto ii = std::next(f.begin()), end = f.end(); ii != end;) {
7272
auto *bb = &*ii++;
73-
if (!reachable.isVisited(bb)) {
73+
if (!reachable.isReachable(bb)) {
7474
bb->removeDeadBlock();
7575
changed = true;
7676
}

0 commit comments

Comments
 (0)