diff options
author | Chris Lattner <sabre@nondot.org> | 2006-10-28 06:44:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-10-28 06:44:56 +0000 |
commit | 27e1f90d8551b84db910c93ab21c941031c18b60 (patch) | |
tree | 99dd30ab688bbda90eaa66cdad0aac6efd0342c7 /include/llvm/Transforms/Utils/BasicBlockUtils.h | |
parent | f6de8ad1a26a84c9713ede78df59d5ca579fa9a8 (diff) | |
download | external_llvm-27e1f90d8551b84db910c93ab21c941031c18b60.tar.gz external_llvm-27e1f90d8551b84db910c93ab21c941031c18b60.tar.bz2 external_llvm-27e1f90d8551b84db910c93ab21c941031c18b60.zip |
Expose a smarter way to break critical edges.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31256 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms/Utils/BasicBlockUtils.h')
-rw-r--r-- | include/llvm/Transforms/Utils/BasicBlockUtils.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/include/llvm/Transforms/Utils/BasicBlockUtils.h b/include/llvm/Transforms/Utils/BasicBlockUtils.h index 3853901b30..0bfb6f750a 100644 --- a/include/llvm/Transforms/Utils/BasicBlockUtils.h +++ b/include/llvm/Transforms/Utils/BasicBlockUtils.h @@ -63,9 +63,15 @@ bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum); /// split the critical edge. This will update DominatorSet, ImmediateDominator, /// DominatorTree, and DominatorFrontier information if it is available, thus /// calling this pass will not invalidate either of them. This returns true if -/// the edge was split, false otherwise. +/// the edge was split, false otherwise. If MergeIdenticalEdges is true (the +/// default), *all* edges from TI to the specified successor will be merged into +/// the same critical edge block. This is most commonly interesting with switch +/// instructions, which may have many edges to any one destination. This +/// ensures that all edges to that dest go to one block instead of each going to +/// a different block, but isn't the standard definition of a "critical edge". /// -bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P = 0); +bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P = 0, + bool MergeIdenticalEdges = false); inline bool SplitCriticalEdge(BasicBlock *BB, succ_iterator SI, Pass *P = 0) { return SplitCriticalEdge(BB->getTerminator(), SI.getSuccessorIndex(), P); @@ -89,13 +95,14 @@ inline bool SplitCriticalEdge(BasicBlock *Succ, pred_iterator PI, Pass *P = 0) { /// and return true, otherwise return false. This method requires that there be /// an edge between the two blocks. If P is specified, it updates the analyses /// described above. -inline bool SplitCriticalEdge(BasicBlock *Src, BasicBlock *Dst, Pass *P = 0) { +inline bool SplitCriticalEdge(BasicBlock *Src, BasicBlock *Dst, Pass *P = 0, + bool MergeIdenticalEdges = false) { TerminatorInst *TI = Src->getTerminator(); unsigned i = 0; while (1) { assert(i != TI->getNumSuccessors() && "Edge doesn't exist!"); if (TI->getSuccessor(i) == Dst) - return SplitCriticalEdge(TI, i, P); + return SplitCriticalEdge(TI, i, P, MergeIdenticalEdges); ++i; } } |