[PATCH] D62633: Recommit r360171: [DAGCombiner] Avoid creating large tokenfactors in visitTokenFactor.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 16:00:36 PDT 2019
fhahn created this revision.
fhahn added reviewers: niravd, spatel, craig.topper, rupprecht.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
If we hit the limit, we do expand the outstanding tokenfactors.
Otherwise, we might drop nodes with users in the unexpanded
tokenfactors. This fixes the crashes reported by Jordan Rupprecht.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62633
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
@@ -1800,9 +1800,20 @@
// Iterate through token factors. The TFs grows when new token factors are
// encountered.
- for (unsigned i = 0; i < TFs.size(); ++i) {
- SDNode *TF = TFs[i];
+ bool CompletelyExpanded = true;
+ for (unsigned i = 0; i < TFs.size() ; ++i) {
+ // Limit number of nodes to inline, to avoid quadratic compile times.
+ // Expand outstanding tokenfactors, otherwise we might drop Ops with
+ // users in unexpanded tokenfactors.
+ if (Ops.size() > 2048) {
+ CompletelyExpanded = false;
+ for (; i < TFs.size(); i++)
+ for (const SDValue &Op : TFs[i]->op_values())
+ Ops.push_back(Op);
+ break;
+ }
+ SDNode *TF = TFs[i];
// Check each of the operands.
for (const SDValue &Op : TF->op_values()) {
switch (Op.getOpcode()) {
@@ -1923,7 +1934,7 @@
// The entry token is the only possible outcome.
Result = DAG.getEntryNode();
} else {
- if (DidPruneOps) {
+ if (DidPruneOps && CompletelyExpanded) {
SmallVector<SDValue, 8> PrunedOps;
//
for (const SDValue &Op : Ops) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62633.202073.patch
Type: text/x-patch
Size: 1342 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190529/c84eddf3/attachment.bin>
More information about the llvm-commits
mailing list