Skip to content

Commit 3715d4c

Browse files
authored
Merge pull request #8864 from eeckstein/escape-analysis
2 parents 84f533a + d9c71e8 commit 3715d4c

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/SILOptimizer/Analysis/EscapeAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ void EscapeAnalysis::analyzeInstruction(SILInstruction *I,
13541354
case ValueKind::ExistentialMetatypeInst:
13551355
case ValueKind::DeallocRefInst:
13561356
case ValueKind::SetDeallocatingInst:
1357+
case ValueKind::FixLifetimeInst:
13571358
// These instructions don't have any effect on escaping.
13581359
return;
13591360
case ValueKind::StrongReleaseInst:

test/SILOptimizer/escape_analysis.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,7 @@ bb3(%6: $X):
14361436
// CHECKL: End
14371437
sil @_T04main1XCfD: $@convention(method) (@owned X) -> () {
14381438
bb0(%0 : $X):
1439+
fix_lifetime %0 : $X
14391440
%1 = tuple ()
14401441
return %1 : $()
14411442
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %target-swift-frontend -parse-as-library -O -module-name=test %s -emit-sil | %FileCheck %s
2+
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
3+
4+
// This is an end-to-end test to check if the array literal in the loop is
5+
// stack promoted.
6+
7+
// CHECK-LABEL: sil @{{.*}}testit
8+
// CHECK: alloc_ref [stack] [tail_elems
9+
10+
public func testit(_ N: Int) {
11+
for _ in 0..<N {
12+
for _ in 0..<10 {
13+
var nums = [Int]()
14+
for _ in 0..<40_000 {
15+
nums += [1, 2, 3, 4, 5, 6, 7]
16+
}
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)