From 2b1b32aebd1afb086a9a3a840392f8a1f941a5ca Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 7 May 2019 16:47:27 +0000 Subject: [PATCH] [DAGCombiner] Avoid creating large tokenfactors in visitTokenFactor When simplifying TokenFactors, we potentially iterate over all operands of a large number of TokenFactors. This causes quadratic compile times in some cases and the large token factors cause additional scalability problems elsewhere. This patch adds some limits to the number of nodes explored for the cases mentioned above. Reviewers: niravd, spatel, craig.topper Reviewed By: niravd Differential Revision: https://reviews.llvm.org/D61397 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360171 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index c23469e166b..a98d151b443 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1792,8 +1792,9 @@ SDValue DAGCombiner::visitTokenFactor(SDNode *N) { TFs.push_back(N); // Iterate through token factors. The TFs grows when new token factors are - // encountered. - for (unsigned i = 0; i < TFs.size(); ++i) { + // encountered. Limit number of nodes to inline, to avoid quadratic compile + // times. + for (unsigned i = 0; i < TFs.size() && Ops.size() <= 2048; ++i) { SDNode *TF = TFs[i]; // Check each of the operands. -- 2.40.0