summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2018-05-17 19:24:03 +0000
committerXinliang David Li <davidxl@google.com>2018-05-17 19:24:03 +0000
commitbc471c39eed35e82d6c39ca28e6e7d78029ee59c (patch)
tree4dbb1a60998930d460546b0d8861dad7419f36fc /llvm/lib/Transforms
parent679083e3d8794726d7320cfb7ecb1bbde8cd762d (diff)
downloadbcm5719-llvm-bc471c39eed35e82d6c39ca28e6e7d78029ee59c.tar.gz
bcm5719-llvm-bc471c39eed35e82d6c39ca28e6e7d78029ee59c.zip
Add a limit for phi folding instcombine
Differential Revision: http://reviews.llvm.org/D47023 llvm-svn: 332653
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
index 91850cee77f..14c3806c40a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
@@ -23,6 +23,10 @@ using namespace llvm::PatternMatch;
#define DEBUG_TYPE "instcombine"
+static cl::opt<unsigned>
+MaxNumPhis("instcombine-max-num-phis", cl::init(512),
+ cl::desc("Maximum number phis to handle in intptr/ptrint folding"));
+
/// The PHI arguments will be folded into a single operation with a PHI node
/// as input. The debug location of the single operation will be the merged
/// locations of the original PHI node arguments.
@@ -176,8 +180,12 @@ Instruction *InstCombiner::FoldIntegerTypedPHI(PHINode &PN) {
assert(AvailablePtrVals.size() == PN.getNumIncomingValues() &&
"Not enough available ptr typed incoming values");
PHINode *MatchingPtrPHI = nullptr;
+ unsigned NumPhis = 0;
for (auto II = BB->begin(), EI = BasicBlock::iterator(BB->getFirstNonPHI());
- II != EI; II++) {
+ II != EI; II++, NumPhis++) {
+ // FIXME: consider handling this in AggressiveInstCombine
+ if (NumPhis > MaxNumPhis)
+ return nullptr;
PHINode *PtrPHI = dyn_cast<PHINode>(II);
if (!PtrPHI || PtrPHI == &PN || PtrPHI->getType() != IntToPtr->getType())
continue;
OpenPOWER on IntegriCloud