llvm.org GIT mirror llvm / 2d43519
Expunge DomSet from BreakCriticalEdges. This is part of the continuing work for PR 1171. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35728 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 12 years ago
1 changed file(s) with 24 addition(s) and 58 deletion(s). Raw diff Collapse all Expand all
3737
3838 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
3939 AU.addPreserved();
40 AU.addPreserved();
4140 AU.addPreserved();
42 AU.addPreserved();
4341 AU.addPreserved();
4442 AU.addPreserved();
4543
107105 }
108106
109107 // SplitCriticalEdge - If this edge is a critical edge, insert a new node to
110 // split the critical edge. This will update DominatorSet, ImmediateDominator,
108 // split the critical edge. This will update ETForest, ImmediateDominator,
111109 // DominatorTree, and DominatorFrontier information if it is available, thus
112110 // calling this pass will not invalidate any of them. This returns true if
113111 // the edge was split, false otherwise. This ensures that all edges to that
175173 if (*I != NewBB)
176174 OtherPreds.push_back(*I);
177175
178 // NewBBDominatesDestBB is valid if OtherPreds is empty, otherwise it isn't
179 // yet computed.
180176 bool NewBBDominatesDestBB = true;
181177
182 // Should we update DominatorSet information?
183 if (DominatorSet *DS = P->getAnalysisToUpdate()) {
184 DominatorSet::iterator DSI = DS->find(TIBB);
185 if (DSI != DS->end()) { // TIBB is reachable?
186 // The blocks that dominate the new one are the blocks that dominate TIBB
187 // plus the new block itself.
188 DominatorSet::DomSetType DomSet = DSI->second; // Copy domset.
189 DomSet.insert(NewBB); // A block always dominates itself.
190 DS->addBasicBlock(NewBB, DomSet);
191
192 // If NewBBDominatesDestBB hasn't been computed yet, do so with DS.
193 if (!OtherPreds.empty()) {
194 while (!OtherPreds.empty() && NewBBDominatesDestBB) {
195 NewBBDominatesDestBB = DS->dominates(DestBB, OtherPreds.back());
196 OtherPreds.pop_back();
197 }
198 OtherPreds.clear();
199 }
200
201 // If NewBBDominatesDestBB, then NewBB dominates DestBB, otherwise it
202 // doesn't dominate anything. If NewBB does dominates DestBB, then it
203 // dominates everything that DestBB dominates.
204 if (NewBBDominatesDestBB) {
205 for (DominatorSet::iterator I = DS->begin(), E = DS->end(); I != E; ++I)
206 if (I->second.count(DestBB))
207 I->second.insert(NewBB);
208 }
209 }
210 }
211
212 // Should we update ImmediateDominator information?
213 if (ImmediateDominators *ID = P->getAnalysisToUpdate()) {
214 // Only do this if TIBB is reachable.
215 if (ID->get(TIBB) || &TIBB->getParent()->getEntryBlock() == TIBB) {
216 // TIBB is the new immediate dominator for NewBB.
217 ID->addNewBlock(NewBB, TIBB);
218
219 // If NewBBDominatesDestBB hasn't been computed yet, do so with ID.
220 if (!OtherPreds.empty()) {
221 while (!OtherPreds.empty() && NewBBDominatesDestBB) {
222 NewBBDominatesDestBB = ID->dominates(DestBB, OtherPreds.back());
223 OtherPreds.pop_back();
224 }
225 OtherPreds.clear();
226 }
227
228 // If NewBBDominatesDestBB, then NewBB dominates DestBB, otherwise it
229 // doesn't dominate anything.
230 if (NewBBDominatesDestBB)
231 ID->setImmediateDominator(DestBB, NewBB);
232 }
233 }
234
235178 // Update the forest?
236179 if (ETForest *EF = P->getAnalysisToUpdate()) {
237180 // NewBB is dominated by TIBB.
252195 EF->setImmediateDominator(DestBB, NewBB);
253196 }
254197
198 // Should we update ImmediateDominator information?
199 if (ImmediateDominators *ID = P->getAnalysisToUpdate()) {
200 // Only do this if TIBB is reachable.
201 if (ID->get(TIBB) || &TIBB->getParent()->getEntryBlock() == TIBB) {
202 // TIBB is the new immediate dominator for NewBB.
203 ID->addNewBlock(NewBB, TIBB);
204
205 // If NewBBDominatesDestBB hasn't been computed yet, do so with ID.
206 if (!OtherPreds.empty()) {
207 while (!OtherPreds.empty() && NewBBDominatesDestBB) {
208 NewBBDominatesDestBB = ID->dominates(DestBB, OtherPreds.back());
209 OtherPreds.pop_back();
210 }
211 OtherPreds.clear();
212 }
213
214 // If NewBBDominatesDestBB, then NewBB dominates DestBB, otherwise it
215 // doesn't dominate anything.
216 if (NewBBDominatesDestBB)
217 ID->setImmediateDominator(DestBB, NewBB);
218 }
219 }
220
255221 // Should we update DominatorTree information?
256222 if (DominatorTree *DT = P->getAnalysisToUpdate()) {
257223 DominatorTree::Node *TINode = DT->getNode(TIBB);