[llvm-commits] CVS: llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Oct 30 20:45:01 PST 2002
Changes in directory llvm/lib/Transforms/Scalar:
BreakCriticalEdges.cpp updated: 1.7 -> 1.8
---
Log message:
BreakCriticalEdges should update dominance frontier information as well as
other dominance stuff. Patch contributed by Casey Carter
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp
diff -u llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp:1.7 llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp:1.8
--- llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp:1.7 Tue Oct 8 16:53:51 2002
+++ llvm/lib/Transforms/Scalar/BreakCriticalEdges.cpp Wed Oct 30 20:44:36 2002
@@ -26,6 +26,7 @@
AU.addPreserved<DominatorSet>();
AU.addPreserved<ImmediateDominators>();
AU.addPreserved<DominatorTree>();
+ AU.addPreserved<DominanceFrontier>();
AU.addPreservedID(LoopPreheadersID); // No preheaders deleted.
}
};
@@ -64,10 +65,11 @@
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);
@@ -120,6 +122,16 @@
//
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);
}
}
More information about the llvm-commits
mailing list