aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-16 19:45:22 +0000
committerChris Lattner <sabre@nondot.org>2004-03-16 19:45:22 +0000
commit4bebf08d152d84970d250feec72fb734cb8a5316 (patch)
treeacf2537f5449e86d0053221cb996297dc6ed32fe /lib/Transforms/Utils/SimplifyCFG.cpp
parentc62db6fc40ac672da9ceabe1956a737cccb9e7a0 (diff)
Do not copy gigantic switch instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12441 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 089d0ac86e..09153ed3bb 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -331,8 +331,15 @@ static void AddPredecessorToBlock(BasicBlock *Succ, BasicBlock *NewPred,
// isValueEqualityComparison - Return true if the specified terminator checks to
// see if a value is equal to constant integer value.
static Value *isValueEqualityComparison(TerminatorInst *TI) {
- if (SwitchInst *SI = dyn_cast<SwitchInst>(TI))
+ if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
+ // Do not permit merging of large switch instructions into their
+ // predecessors unless there is only one predecessor.
+ if (SI->getNumSuccessors() * std::distance(pred_begin(SI->getParent()),
+ pred_end(SI->getParent())) > 128)
+ return 0;
+
return SI->getCondition();
+ }
if (BranchInst *BI = dyn_cast<BranchInst>(TI))
if (BI->isConditional() && BI->getCondition()->hasOneUse())
if (SetCondInst *SCI = dyn_cast<SetCondInst>(BI->getCondition()))