BreakCriticalEdges should update dominance frontier information as well as

other dominance stuff.  Patch contributed by Casey Carter


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4457 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-10-31 02:44:36 +00:00
parent a24e09df76
commit 6918c079a1
2 changed files with 28 additions and 4 deletions

View File

@ -26,6 +26,7 @@ namespace {
AU.addPreserved<DominatorSet>();
AU.addPreserved<ImmediateDominators>();
AU.addPreserved<DominatorTree>();
AU.addPreserved<DominanceFrontier>();
AU.addPreservedID(LoopPreheadersID); // No preheaders deleted.
}
};
@ -64,10 +65,11 @@ void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
assert(isCriticalEdge(TI, SuccNum) &&
"Cannot break a critical edge, if it isn't a critical edge");
BasicBlock *TIBB = TI->getParent();
BasicBlock *DestBB = TI->getSuccessor(SuccNum);
// Create a new basic block, linking it into the CFG.
BasicBlock *NewBB = new BasicBlock(TIBB->getName()+"_crit_edge");
BasicBlock *DestBB = TI->getSuccessor(SuccNum);
BasicBlock *NewBB = new BasicBlock(TIBB->getName() + "." +
DestBB->getName() + "_crit_edge");
// Create our unconditional branch...
BranchInst *BI = new BranchInst(DestBB);
NewBB->getInstList().push_back(BI);
@ -121,6 +123,16 @@ void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
if (TINode) // Don't break unreachable code!
DT->createNewNode(NewBB, TINode);
}
// Should we update DominanceFrontier information?
if (DominanceFrontier *DF = P->getAnalysisToUpdate<DominanceFrontier>()) {
// Since the new block is dominated by its only predecessor TIBB,
// it cannot be in any block's dominance frontier. Its dominance
// frontier is {DestBB}.
DominanceFrontier::DomSetType NewDFSet;
NewDFSet.insert(DestBB);
DF->addBasicBlock(NewBB, NewDFSet);
}
}
// runOnFunction - Loop over all of the edges in the CFG, breaking critical

View File

@ -26,6 +26,7 @@ namespace {
AU.addPreserved<DominatorSet>();
AU.addPreserved<ImmediateDominators>();
AU.addPreserved<DominatorTree>();
AU.addPreserved<DominanceFrontier>();
AU.addPreservedID(LoopPreheadersID); // No preheaders deleted.
}
};
@ -64,10 +65,11 @@ void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
assert(isCriticalEdge(TI, SuccNum) &&
"Cannot break a critical edge, if it isn't a critical edge");
BasicBlock *TIBB = TI->getParent();
BasicBlock *DestBB = TI->getSuccessor(SuccNum);
// Create a new basic block, linking it into the CFG.
BasicBlock *NewBB = new BasicBlock(TIBB->getName()+"_crit_edge");
BasicBlock *DestBB = TI->getSuccessor(SuccNum);
BasicBlock *NewBB = new BasicBlock(TIBB->getName() + "." +
DestBB->getName() + "_crit_edge");
// Create our unconditional branch...
BranchInst *BI = new BranchInst(DestBB);
NewBB->getInstList().push_back(BI);
@ -121,6 +123,16 @@ void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
if (TINode) // Don't break unreachable code!
DT->createNewNode(NewBB, TINode);
}
// Should we update DominanceFrontier information?
if (DominanceFrontier *DF = P->getAnalysisToUpdate<DominanceFrontier>()) {
// Since the new block is dominated by its only predecessor TIBB,
// it cannot be in any block's dominance frontier. Its dominance
// frontier is {DestBB}.
DominanceFrontier::DomSetType NewDFSet;
NewDFSet.insert(DestBB);
DF->addBasicBlock(NewBB, NewDFSet);
}
}
// runOnFunction - Loop over all of the edges in the CFG, breaking critical