forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request swiftlang#3286 from eeckstein/escape-analysis
- Loading branch information
Showing
3 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// RUN: %target-swift-frontend -parse-as-library -O -module-name=test %s -emit-sil | FileCheck %s | ||
|
||
final class Item {} | ||
|
||
final public class Escaper { | ||
var myItem: Item = Item() | ||
|
||
@inline(never) | ||
func update(items: [Item]) { | ||
myItem = items[0] | ||
} | ||
|
||
// CHECK-LABEL: sil [noinline] @_TFC4test7Escaper15badStuffHappensfT_T_ : $@convention(method) (@guaranteed Escaper) -> () { | ||
// CHECK: %2 = alloc_ref $Item | ||
// CHECK: function_ref @swift_bufferAllocateOnStack | ||
// CHECK: return | ||
@inline(never) | ||
public func badStuffHappens() { | ||
// Check that 'item' is not stack promoted, because it escapes to myItem. | ||
let item = Item() | ||
// On the other hand, the array buffer of the array literal should be stack promoted. | ||
update(items:[item]) | ||
} | ||
} | ||
|