File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,11 @@ class MachineDominatorTree : public DomTreeBase<MachineBasicBlock> {
185
185
return Base::findNearestCommonDominator (A, B);
186
186
}
187
187
188
+ // / Returns the nearest common dominator of the given blocks.
189
+ // / If that tree node is a virtual root, a nullptr will be returned.
190
+ MachineBasicBlock *
191
+ findNearestCommonDominator (ArrayRef<MachineBasicBlock *> Blocks) const ;
192
+
188
193
MachineDomTreeNode *operator [](MachineBasicBlock *BB) const {
189
194
applySplitCriticalEdges ();
190
195
return Base::getNode (BB);
Original file line number Diff line number Diff line change @@ -189,3 +189,19 @@ void MachineDominatorTree::applySplitCriticalEdges() const {
189
189
NewBBs.clear ();
190
190
CriticalEdgesToSplit.clear ();
191
191
}
192
+
193
+ MachineBasicBlock *MachineDominatorTree::findNearestCommonDominator (
194
+ ArrayRef<MachineBasicBlock *> Blocks) const {
195
+ assert (!Blocks.empty ());
196
+
197
+ MachineBasicBlock *NCD = Blocks.front ();
198
+ for (MachineBasicBlock *BB : Blocks.drop_front ()) {
199
+ NCD = Base::findNearestCommonDominator (NCD, BB);
200
+
201
+ // Stop when the root is reached.
202
+ if (Base::isVirtualRoot (Base::getNode (NCD)))
203
+ return nullptr ;
204
+ }
205
+
206
+ return NCD;
207
+ }
You can’t perform that action at this time.
0 commit comments