Skip to content

Commit d01aa21

Browse files
authored
Merge pull request #34867 from eeckstein/fix-escape-analysis
EscapeAnalysis: fix a quadratic behavior in ConnectionGraph::getNode
2 parents 9e6ea6c + f149168 commit d01aa21

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/SILOptimizer/Analysis/EscapeAnalysis.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ EscapeAnalysis::ConnectionGraph::getNode(SILValue V) {
450450
if (Node) {
451451
CGNode *targetNode = Node->getMergeTarget();
452452
targetNode->mergeFlags(false /*isInterior*/, hasReferenceOnly);
453+
// Update the node in Values2Nodes, so that next time we don't need to find
454+
// the final merge target.
455+
Node = targetNode;
453456
return targetNode;
454457
}
455458
if (isa<SILFunctionArgument>(ptrBase)) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %gyb %s > %t/main.swift
3+
4+
// The compiler should finish in less than 2 minautes. To give some slack,
5+
// specify a timeout of 4 minutes.
6+
// If the compiler needs more than 5 minutes, there is probably a real problem.
7+
// So please don't just increase the timeout in case this fails.
8+
9+
// RUN: %{python} %S/../../test/Inputs/timeout.py 240 %target-swift-frontend -O -parse-as-library -sil-verify-none -c %t/main.swift -o %t/main.o
10+
11+
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
12+
// REQUIRES: long_test
13+
// REQUIRES: CPU=arm64 || CPU=x86_64
14+
15+
public struct TestStruct {
16+
public static var a: [[Int]] {
17+
var a: [[Int]] = Array(repeating: Array(repeating: 0, count: 4), count: 2000)
18+
19+
% for i in range(2000):
20+
a[${i}] = [${i * 4}, ${i * 4 + 1}, ${i * 4 + 2}, ${i * 4 + 3}]
21+
% end
22+
23+
return a
24+
}
25+
}
26+
27+

0 commit comments

Comments
 (0)