Skip to content

Commit e4bb23a

Browse files
committed
[NFC] ReachableBlocks: Add ::hasUnreachableBlocks.
The method walks over the blocks of the function testing each for reachability and returns false on the first that is not.
1 parent 038740d commit e4bb23a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/swift/SILOptimizer/Utils/BasicBlockOptUtils.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ class ReachableBlocks {
5353
return isVisited(block);
5454
}
5555

56+
bool hasUnreachableBlocks() const {
57+
assert(isComputed);
58+
for (auto &block : *visited.getFunction()) {
59+
if (!isReachable(&block)) {
60+
return true;
61+
}
62+
}
63+
return false;
64+
}
65+
5666
private:
5767
/// Invoke \p visitor for each reachable block in \p f in worklist order (at
5868
/// least one predecessor has been visited--defs are always visited before

0 commit comments

Comments
 (0)