@@ -45,9 +45,6 @@ class MachineDominatorTree : public MachineFunctionPass {
45
45
MachineBasicBlock *FromBB;
46
46
MachineBasicBlock *ToBB;
47
47
MachineBasicBlock *NewBB;
48
- CriticalEdge (MachineBasicBlock *FromBB, MachineBasicBlock *ToBB,
49
- MachineBasicBlock *NewBB)
50
- : FromBB(FromBB), ToBB(ToBB), NewBB(NewBB) {}
51
48
};
52
49
53
50
// / \brief Pile up all the critical edges to be split.
@@ -67,74 +64,7 @@ class MachineDominatorTree : public MachineFunctionPass {
67
64
// / the fast query path of DT as much as possible.
68
65
// /
69
66
// / \post CriticalEdgesToSplit.empty().
70
- void applySplitCriticalEdges () const {
71
- // Bail out early if there is nothing to do.
72
- if (CriticalEdgesToSplit.empty ())
73
- return ;
74
-
75
- // For each element in CriticalEdgesToSplit, remember whether or
76
- // not element is the new immediate domminator of its successor.
77
- // The mapping is done by index, i.e., the information for the ith
78
- // element of CriticalEdgesToSplit is the ith element of IsNewIDom.
79
- SmallVector<bool , 32 > IsNewIDom;
80
- IsNewIDom.resize (CriticalEdgesToSplit.size ());
81
- size_t Idx = 0 ;
82
-
83
- // Collect all the dominance properties info, before invalidating
84
- // the underlying DT.
85
- for (CriticalEdge &Edge : CriticalEdgesToSplit) {
86
- // Update dominator information.
87
- MachineBasicBlock *Succ = Edge.ToBB ;
88
- MachineDomTreeNode *SucccDTNode = DT->getNode (Succ);
89
-
90
- IsNewIDom[Idx] = true ;
91
- for (MachineBasicBlock *PredBB : Succ->predecessors ()) {
92
- if (PredBB == Edge.NewBB )
93
- continue ;
94
- // If we are in this situation:
95
- // FromBB1 FromBB2
96
- // + +
97
- // + + + +
98
- // + + + +
99
- // ... Split1 Split2 ...
100
- // + +
101
- // + +
102
- // +
103
- // Succ
104
- // Instead of checking the domiance property with Split2, we
105
- // check it with FromBB2 since Split2 is still unknown of the
106
- // underlying DT structure.
107
- if (NewBBs.count (PredBB)) {
108
- assert (PredBB->pred_size () == 1 && " A basic block resulting from a "
109
- " critical edge split has more "
110
- " than one predecessor!" );
111
- PredBB = *PredBB->pred_begin ();
112
- }
113
- if (!DT->dominates (SucccDTNode, DT->getNode (PredBB))) {
114
- IsNewIDom[Idx] = false ;
115
- break ;
116
- }
117
- }
118
- ++Idx;
119
- }
120
-
121
- // Now, update DT with the collected dominance properties info.
122
- Idx = 0 ;
123
- for (CriticalEdge &Edge : CriticalEdgesToSplit) {
124
- // We know FromBB dominates NewBB.
125
- MachineDomTreeNode *NewDTNode = DT->addNewBlock (Edge.NewBB , Edge.FromBB );
126
- MachineDomTreeNode *SucccDTNode = DT->getNode (Edge.ToBB );
127
-
128
- // If all the other predecessors of "Succ" are dominated by "Succ" itself
129
- // then the new block is the new immediate dominator of "Succ". Otherwise,
130
- // the new block doesn't dominate anything.
131
- if (IsNewIDom[Idx])
132
- DT->changeImmediateDominator (SucccDTNode, NewDTNode);
133
- ++Idx;
134
- }
135
- NewBBs.clear ();
136
- CriticalEdgesToSplit.clear ();
137
- }
67
+ void applySplitCriticalEdges () const ;
138
68
139
69
public:
140
70
static char ID; // Pass ID, replacement for typeid
@@ -307,7 +237,7 @@ class MachineDominatorTree : public MachineFunctionPass {
307
237
(void )Inserted;
308
238
assert (Inserted &&
309
239
" A basic block inserted via edge splitting cannot appear twice" );
310
- CriticalEdgesToSplit.push_back (CriticalEdge ( FromBB, ToBB, NewBB) );
240
+ CriticalEdgesToSplit.push_back ({ FromBB, ToBB, NewBB} );
311
241
}
312
242
};
313
243
0 commit comments