summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-31 02:44:36 +0000
committerChris Lattner <sabre@nondot.org>2002-10-31 02:44:36 +0000
commit12764c85e833c00e8c3187e8c3873a934c508fbf (patch)
tree7e271c1d8b042e016f8f263fdab0004c6d12380f /llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp
parent869142e0d7c588fac3d05280801228d1c3339094 (diff)
downloadbcm5719-llvm-12764c85e833c00e8c3187e8c3873a934c508fbf.tar.gz
bcm5719-llvm-12764c85e833c00e8c3187e8c3873a934c508fbf.zip
BreakCriticalEdges should update dominance frontier information as well as
other dominance stuff. Patch contributed by Casey Carter llvm-svn: 4457
Diffstat (limited to 'llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp b/llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp
index 0c4974db10a..c44f9d324ec 100644
--- a/llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp
+++ b/llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp
@@ -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
OpenPOWER on IntegriCloud