diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-16 19:45:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-16 19:45:22 +0000 |
commit | 4bebf08d152d84970d250feec72fb734cb8a5316 (patch) | |
tree | acf2537f5449e86d0053221cb996297dc6ed32fe /lib/Transforms/Scalar | |
parent | c62db6fc40ac672da9ceabe1956a737cccb9e7a0 (diff) | |
download | external_llvm-4bebf08d152d84970d250feec72fb734cb8a5316.zip external_llvm-4bebf08d152d84970d250feec72fb734cb8a5316.tar.gz external_llvm-4bebf08d152d84970d250feec72fb734cb8a5316.tar.bz2 |
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/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/TailDuplication.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index a3980b3..00d7f26 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -91,7 +91,8 @@ bool TailDup::shouldEliminateUnconditionalBranch(TerminatorInst *TI) { if (Dest == BI->getParent()) return false; // Do not loop infinitely! // Do not inline a block if we will just get another branch to the same block! - if (BranchInst *DBI = dyn_cast<BranchInst>(Dest->getTerminator())) + TerminatorInst *DTI = Dest->getTerminator(); + if (BranchInst *DBI = dyn_cast<BranchInst>(DTI)) if (DBI->isUnconditional() && DBI->getSuccessor(0) == Dest) return false; // Do not loop infinitely! @@ -110,6 +111,15 @@ bool TailDup::shouldEliminateUnconditionalBranch(TerminatorInst *TI) { for (unsigned Size = 0; I != Dest->end(); ++Size, ++I) if (Size == 6) return false; // The block is too large... + + // Do not tail duplicate a block that has thousands of successors into a block + // with a single successor if the block has many other predecessors. This can + // cause an N^2 explosion in CFG edges (and PHI node entries), as seen in + // cases that have a large number of indirect gotos. + if (DTI->getNumSuccessors() > 8) + if (std::distance(PI, PE) * DTI->getNumSuccessors() > 128) + return false; + return true; } |