namespace {
struct VISIBILITY_HIDDEN BreakCriticalEdges : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
- BreakCriticalEdges() : FunctionPass((intptr_t)&ID) {}
+ BreakCriticalEdges() : FunctionPass(&ID) {}
virtual bool runOnFunction(Function &F);
AU.addPreservedID(LoopSimplifyID);
}
};
-
- char BreakCriticalEdges::ID = 0;
- RegisterPass<BreakCriticalEdges> X("break-crit-edges",
- "Break critical edges in CFG");
}
+char BreakCriticalEdges::ID = 0;
+static RegisterPass<BreakCriticalEdges>
+X("break-crit-edges", "Break critical edges in CFG");
+
// Publically exposed interface to pass...
-const PassInfo *llvm::BreakCriticalEdgesID = X.getPassInfo();
+const PassInfo *const llvm::BreakCriticalEdgesID = &X;
FunctionPass *llvm::createBreakCriticalEdgesPass() {
return new BreakCriticalEdges();
}
return false;
}
-// SplitCriticalEdge - If this edge is a critical edge, insert a new node to
-// split the critical edge. This will update DominatorTree, and DominatorFrontier
-// information if it is available, thus calling this pass will not invalidate
-// any of them. This returns true if the edge was split, false otherwise.
-// This ensures that all edges to that dest go to one block instead of each
-// going to a different block.
+/// SplitCriticalEdge - If this edge is a critical edge, insert a new node to
+/// split the critical edge. This will update DominatorTree and
+/// DominatorFrontier information if it is available, thus calling this pass
+/// will not invalidate any of them. This returns true if the edge was split,
+/// false otherwise. This ensures that all edges to that dest go to one block
+/// instead of each going to a different block.
//
bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P,
bool MergeIdenticalEdges) {
bool NewBBDominatesDestBB = true;
// Should we update DominatorTree information?
- if (DominatorTree *DT = P->getAnalysisToUpdate<DominatorTree>()) {
+ if (DominatorTree *DT = P->getAnalysisIfAvailable<DominatorTree>()) {
DomTreeNode *TINode = DT->getNode(TIBB);
// The new block is not the immediate dominator for any other nodes, but
}
// Should we update DominanceFrontier information?
- if (DominanceFrontier *DF = P->getAnalysisToUpdate<DominanceFrontier>()) {
+ if (DominanceFrontier *DF = P->getAnalysisIfAvailable<DominanceFrontier>()) {
// If NewBBDominatesDestBB hasn't been computed yet, do so with DF.
if (!OtherPreds.empty()) {
// FIXME: IMPLEMENT THIS!
DominanceFrontier::iterator I = DF->find(DestBB);
if (I != DF->end()) {
DF->addBasicBlock(NewBB, I->second);
- // However NewBB's frontier does not include DestBB.
- DominanceFrontier::iterator NF = DF->find(NewBB);
- DF->removeFromFrontier(NF, DestBB);
+
+ if (I->second.count(DestBB)) {
+ // However NewBB's frontier does not include DestBB.
+ DominanceFrontier::iterator NF = DF->find(NewBB);
+ DF->removeFromFrontier(NF, DestBB);
+ }
}
else
DF->addBasicBlock(NewBB, DominanceFrontier::DomSetType());
}
// Update LoopInfo if it is around.
- if (LoopInfo *LI = P->getAnalysisToUpdate<LoopInfo>()) {
+ if (LoopInfo *LI = P->getAnalysisIfAvailable<LoopInfo>()) {
// If one or the other blocks were not in a loop, the new block is not
// either, and thus LI doesn't need to be updated.
if (Loop *TIL = LI->getLoopFor(TIBB))