File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,19 @@ class DominanceInfo : public DominatorTreeBase {
88
88
}
89
89
};
90
90
91
+ // / Compute a single block's dominance frontier.
92
+ // /
93
+ // / Precondition: no critical edges (OSSA)
94
+ // /
95
+ // / Postcondition: each block in \p frontier is dominated by \p root and either
96
+ // / exits the function or has a single successor that is not dominated by \p
97
+ // / root.
98
+ // /
99
+ // / With no critical edges, the dominance frontier is identified simply by leaf
100
+ // / blocks in the dominance subtree.
101
+ void computeDominanceFrontier (SILBasicBlock *root, DominanceInfo *domTree,
102
+ SmallVectorImpl<SILBasicBlock *> &frontier);
103
+
91
104
// / Helper class for visiting basic blocks in dominance order, based on a
92
105
// / worklist algorithm. Example usage:
93
106
// / \code
Original file line number Diff line number Diff line change @@ -141,3 +141,22 @@ void PostDominanceInfo::verify() const {
141
141
abort ();
142
142
}
143
143
}
144
+
145
+ void
146
+ swift::computeDominanceFrontier (SILBasicBlock *root,
147
+ DominanceInfo *domTree,
148
+ SmallVectorImpl<SILBasicBlock *> &frontier) {
149
+ auto *function = root->getParent ();
150
+ assert (function->hasOwnership ());
151
+ assert (frontier.empty ());
152
+
153
+ DominanceOrder domOrder (root, domTree);
154
+ while (SILBasicBlock *block = domOrder.getNext ()) {
155
+ DominanceInfoNode *domNode = domTree->getNode (block);
156
+ if (domNode->isLeaf ()) {
157
+ frontier.push_back (block);
158
+ continue ;
159
+ }
160
+ domOrder.pushChildren (block);
161
+ }
162
+ }
You can’t perform that action at this time.
0 commit comments