File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
lib/Transforms/InstCombine Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ using namespace llvm::PatternMatch;
23
23
24
24
#define DEBUG_TYPE " instcombine"
25
25
26
+ static cl::opt<unsigned >
27
+ MaxNumPhis (" instcombine-max-num-phis" , cl::init(512 ),
28
+ cl::desc(" Maximum number phis to handle in intptr/ptrint folding" ));
29
+
26
30
// / The PHI arguments will be folded into a single operation with a PHI node
27
31
// / as input. The debug location of the single operation will be the merged
28
32
// / locations of the original PHI node arguments.
@@ -176,8 +180,12 @@ Instruction *InstCombiner::FoldIntegerTypedPHI(PHINode &PN) {
176
180
assert (AvailablePtrVals.size () == PN.getNumIncomingValues () &&
177
181
" Not enough available ptr typed incoming values" );
178
182
PHINode *MatchingPtrPHI = nullptr ;
183
+ unsigned NumPhis = 0 ;
179
184
for (auto II = BB->begin (), EI = BasicBlock::iterator (BB->getFirstNonPHI ());
180
- II != EI; II++) {
185
+ II != EI; II++, NumPhis++) {
186
+ // FIXME: consider handling this in AggressiveInstCombine
187
+ if (NumPhis > MaxNumPhis)
188
+ return nullptr ;
181
189
PHINode *PtrPHI = dyn_cast<PHINode>(II);
182
190
if (!PtrPHI || PtrPHI == &PN || PtrPHI->getType () != IntToPtr->getType ())
183
191
continue ;
You can’t perform that action at this time.
0 commit comments