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 {
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 visited.contains (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
@@ -55,9 +62,6 @@ class ReachableBlocks {
5562 // /
5663 // / Returns true if all reachable blocks were visited.
5764 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); }
6165};
6266
6367// / 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) {
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 }
You can’t perform that action at this time.
0 commit comments