diff options
author | Chris Lattner <sabre@nondot.org> | 2006-10-28 06:58:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-10-28 06:58:17 +0000 |
commit | b57de3328d3826e1f270f3a38256ff67aaec1871 (patch) | |
tree | b01fcf7a41db1dd1267c586fbfca631a8f09c623 | |
parent | 0997fadc3781c3f7e9386ec0f232aaba795f14e3 (diff) | |
download | external_llvm-b57de3328d3826e1f270f3a38256ff67aaec1871.zip external_llvm-b57de3328d3826e1f270f3a38256ff67aaec1871.tar.gz external_llvm-b57de3328d3826e1f270f3a38256ff67aaec1871.tar.bz2 |
add option to isCriticalEdge
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31258 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Transforms/Utils/BasicBlockUtils.h | 3 | ||||
-rw-r--r-- | lib/Transforms/Utils/BreakCriticalEdges.cpp | 15 |
2 files changed, 14 insertions, 4 deletions
diff --git a/include/llvm/Transforms/Utils/BasicBlockUtils.h b/include/llvm/Transforms/Utils/BasicBlockUtils.h index 0bfb6f7..25f3839 100644 --- a/include/llvm/Transforms/Utils/BasicBlockUtils.h +++ b/include/llvm/Transforms/Utils/BasicBlockUtils.h @@ -57,7 +57,8 @@ void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum); /// Critical edges are edges from a block with multiple successors to a block /// with multiple predecessors. /// -bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum); +bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum, + bool AllowIdenticalEdges = false); /// SplitCriticalEdge - If this edge is a critical edge, insert a new node to /// split the critical edge. This will update DominatorSet, ImmediateDominator, diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index 5bb513f..58f0347 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -84,7 +84,8 @@ bool BreakCriticalEdges::runOnFunction(Function &F) { // 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 @@ bool llvm::isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) { // 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::isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) { // 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); |