Skip to content

EscapeAnalysis: handle fix_lifetime instructions #8864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/SILOptimizer/Analysis/EscapeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@ void EscapeAnalysis::analyzeInstruction(SILInstruction *I,
case ValueKind::ExistentialMetatypeInst:
case ValueKind::DeallocRefInst:
case ValueKind::SetDeallocatingInst:
case ValueKind::FixLifetimeInst:
// These instructions don't have any effect on escaping.
return;
case ValueKind::StrongReleaseInst:
Expand Down
1 change: 1 addition & 0 deletions test/SILOptimizer/escape_analysis.sil
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@ bb3(%6: $X):
// CHECKL: End
sil @_T04main1XCfD: $@convention(method) (@owned X) -> () {
bb0(%0 : $X):
fix_lifetime %0 : $X
%1 = tuple ()
return %1 : $()
}
Expand Down
19 changes: 19 additions & 0 deletions test/SILOptimizer/stack_promotion_array_literal.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %target-swift-frontend -parse-as-library -O -module-name=test %s -emit-sil | %FileCheck %s
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib

// This is an end-to-end test to check if the array literal in the loop is
// stack promoted.

// CHECK-LABEL: sil @{{.*}}testit
// CHECK: alloc_ref [stack] [tail_elems

public func testit(_ N: Int) {
for _ in 0..<N {
for _ in 0..<10 {
var nums = [Int]()
for _ in 0..<40_000 {
nums += [1, 2, 3, 4, 5, 6, 7]
}
}
}
}