[PATCH] D47023: Limit the number of phis in intptr/ptrint folding

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 17 12:27:56 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL332653: Add a limit for phi folding instcombine (authored by davidxl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47023?vs=147366&id=147373#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47023

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp


Index: llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
@@ -23,6 +23,10 @@
 
 #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 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47023.147373.patch
Type: text/x-patch
Size: 1294 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180517/bb09e772/attachment.bin>


More information about the llvm-commits mailing list