[PATCH] D118877: [DagCombine] Increase depth by number of operands to avoid a pathological compile time.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 2 23:46:50 PST 2022


asbirlea created this revision.
asbirlea added reviewers: niravd, RKSimon, bjope, spatel, craig.topper.
Herald added subscribers: ecnelises, steven.zhang, hiraditya.
asbirlea requested review of this revision.
Herald added a project: LLVM.

We're hitting a pathological compile-time case, profiled to be in
DagCombiner::visitTokenFactor and many inserts into a SmallPtrSet.
It looks like one of the paths around findBetterNeighborChains is not
capped and leads to this.

This patch resolves the issue. Looking for feedback if this solution
looks reasonable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118877

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -23928,7 +23928,7 @@
       }
       for (unsigned n = Chain.getNumOperands(); n;)
         Chains.push_back(Chain.getOperand(--n));
-      ++Depth;
+      Depth += Chain.getNumOperands();
       continue;
     }
     // Everything else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118877.405535.patch
Type: text/x-patch
Size: 461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220203/fe907771/attachment.bin>


More information about the llvm-commits mailing list