File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
include/swift/SILOptimizer/Utils Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,13 @@ class ReachableBlocks {
47
47
// / Populate `visited` with the blocks reachable in the function.
48
48
void compute ();
49
49
50
+ // / Whether `block` is reachable from the entry block.
51
+ bool isReachable (SILBasicBlock *block) const {
52
+ assert (isComputed);
53
+ return visited.contains (block);
54
+ }
55
+
56
+ private:
50
57
// / Invoke \p visitor for each reachable block in \p f in worklist order (at
51
58
// / least one predecessor has been visited--defs are always visited before
52
59
// / uses except for phi-type block args). The \p visitor takes a block
@@ -55,9 +62,6 @@ class ReachableBlocks {
55
62
// /
56
63
// / Returns true if all reachable blocks were visited.
57
64
bool visit (function_ref<bool (SILBasicBlock *)> visitor);
58
-
59
- // / Return true if \p bb has been visited.
60
- bool isVisited (SILBasicBlock *bb) const { return visited.contains (bb); }
61
65
};
62
66
63
67
// / Computes the set of blocks from which a path to the return-block exists.
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ bool swift::removeUnreachableBlocks(SILFunction &f) {
70
70
bool changed = false ;
71
71
for (auto ii = std::next (f.begin ()), end = f.end (); ii != end;) {
72
72
auto *bb = &*ii++;
73
- if (!reachable.isVisited (bb)) {
73
+ if (!reachable.isReachable (bb)) {
74
74
bb->removeDeadBlock ();
75
75
changed = true ;
76
76
}
You can’t perform that action at this time.
0 commit comments