[llvm-commits] CVS: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
Chris Lattner
sabre at nondot.org
Fri Oct 27 23:58:32 PDT 2006
Changes in directory llvm/lib/Transforms/Utils:
BreakCriticalEdges.cpp updated: 1.35 -> 1.36
---
Log message:
add option to isCriticalEdge
---
Diffs of the changes: (+12 -3)
BreakCriticalEdges.cpp | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
Index: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
diff -u llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.35 llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.36
--- llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.35 Sat Oct 28 01:44:56 2006
+++ llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp Sat Oct 28 01:58:17 2006
@@ -84,7 +84,8 @@
// Critical edges are edges from a block with multiple successors to a block
// with multiple predecessors.
//
-bool llvm::isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
+bool llvm::isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum,
+ bool AllowIdenticalEdges) {
assert(SuccNum < TI->getNumSuccessors() && "Illegal edge specification!");
if (TI->getNumSuccessors() == 1) return false;
@@ -93,8 +94,16 @@
// If there is more than one predecessor, this is a critical edge...
assert(I != E && "No preds, but we have an edge to the block?");
+ const BasicBlock *FirstPred = *I;
++I; // Skip one edge due to the incoming arc from TI.
- return I != E;
+ if (!AllowIdenticalEdges)
+ return I != E;
+
+ // If AllowIdenticalEdges is true, then we allow this edge to be considered
+ // non-critical iff all preds come from TI's block.
+ for (; I != E; ++I)
+ if (*I != FirstPred) return true;
+ return false;
}
// SplitCriticalEdge - If this edge is a critical edge, insert a new node to
@@ -106,7 +115,7 @@
//
bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P,
bool MergeIdenticalEdges) {
- if (!isCriticalEdge(TI, SuccNum)) return false;
+ if (!isCriticalEdge(TI, SuccNum, MergeIdenticalEdges)) return false;
BasicBlock *TIBB = TI->getParent();
BasicBlock *DestBB = TI->getSuccessor(SuccNum);
More information about the llvm-commits
mailing list