Skip to content

Commit fb4bfef

Browse files
committed
[NFC] Update CHECK lines for lifetime dependence tests
1 parent 6a86bf3 commit fb4bfef

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

test/SIL/buffer_view_prototype.swift renamed to test/SIL/lifetime_dependence_buffer_view_test.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// REQUIRES: swift_in_compiler
1010
// REQUIRES: noncopyable_generics
1111

12-
// Incrementally testing https://github.pie.apple.com/guillaume-l/BufferView with lifetime dependence
13-
1412
// TODO: Use real Range
1513
public struct FakeRange<Bound> {
1614
public let lowerBound: Bound
@@ -65,6 +63,7 @@ public struct BufferView<Element> : ~Escapable {
6563
public let count: Int
6664
private var baseAddress: UnsafeRawPointer { start._rawValue }
6765

66+
// CHECK: sil @$s31lifetime_dependence_scope_fixup10BufferViewV11baseAddress5count9dependsOnACyxGSVYls_Siqd__htclufC : $@convention(method) <Element><Owner> (UnsafeRawPointer, Int, @in_guaranteed Owner, @thin BufferView<Element>.Type) -> _scope(1) @owned BufferView<Element> {
6867
public init<Owner>(
6968
baseAddress: UnsafeRawPointer,
7069
count: Int,
@@ -74,6 +73,7 @@ public struct BufferView<Element> : ~Escapable {
7473
start: .init(rawValue: baseAddress), count: count, dependsOn: owner
7574
)
7675
}
76+
// CHECK: sil hidden @$s31lifetime_dependence_scope_fixup10BufferViewV5start5count9dependsOnACyxGAA0eF5IndexVyxGYls_Siqd__htclufC : $@convention(method) <Element><Owner> (BufferViewIndex<Element>, Int, @in_guaranteed Owner, @thin BufferView<Element>.Type) -> _scope(1) @owned BufferView<Element> {
7777
init<Owner>(
7878
start index: BufferViewIndex<Element>,
7979
count: Int,
@@ -122,6 +122,7 @@ extension BufferView {
122122
}
123123
}
124124

125+
// CHECK: sil @$s31lifetime_dependence_scope_fixup10BufferViewVyACyxGAA9FakeRangeVyAA0eF5IndexVyxGGcig : $@convention(method) <Element> (FakeRange<BufferViewIndex<Element>>, @guaranteed BufferView<Element>) -> _scope(0) @owned BufferView<Element> {
125126
public subscript(bounds: FakeRange<BufferViewIndex<Element>>) -> Self {
126127
get {
127128
BufferView(
@@ -140,6 +141,7 @@ extension Array {
140141
// }
141142
// TODO: Implementation of getter should not need a temporary
142143
// rdar://123071321
144+
// CHECK: sil hidden @$sSa31lifetime_dependence_scope_fixupE4viewAA10BufferViewVyxGvg : $@convention(method) <Element> (@guaranteed Array<Element>) -> _scope(0) @owned BufferView<Element> {
143145
var view: BufferView<Element> {
144146
var _view : BufferView<Element>?
145147
withUnsafePointer(to:self) {

test/SILOptimizer/lifetime_dependence_scope_fixup.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ func test1(_ a: Array<Int>) {
112112
}
113113
}
114114

115+
// CHECK-LABEL: sil private @$s31lifetime_dependence_scope_fixup5test2yySaySiGFySWXEfU_ : $@convention(thin) @substituted <τ_0_0> (UnsafeRawBufferPointer) -> (@out τ_0_0, @error any Error) for <()> {
116+
// CHECK: [[CONT:%.*]] = alloc_stack [lexical] $NCContainer, var, name "x"
117+
// CHECK: [[BA:%.*]] = begin_access [read] [static] [[CONT]] : $*NCContainer
118+
// CHECK: [[LD:%.*]] = load [[CONT]] : $*NCContainer
119+
// CHECK: [[FUNC:%.*]] = function_ref @$s31lifetime_dependence_scope_fixup16getBorrowingViewyAA0G0VAA11NCContainerVYlsF : $@convention(thin) (@guaranteed NCContainer) -> _scope(1) @owned View
120+
// CHECK: [[VIEW:%.*]] = apply [[FUNC]]([[LD]]) : $@convention(thin) (@guaranteed NCContainer) -> _scope(1) @owned View
121+
// CHECK: [[MDI:%.*]] = mark_dependence [nonescaping] [[VIEW]] : $View on [[BA]] : $*NCContainer
122+
// CHECK: [[USE:%.*]] = function_ref @$s31lifetime_dependence_scope_fixup3useyyAA4ViewVF : $@convention(thin) (@guaranteed View) -> ()
123+
// CHECK: apply [[USE]]([[MDI]]) : $@convention(thin) (@guaranteed View) -> ()
124+
// CHECK: [[CONSUME:%.*]] = function_ref @$s31lifetime_dependence_scope_fixup7consumeyyAA4ViewVnF : $@convention(thin) (@owned View) -> ()
125+
// CHECK: apply [[CONSUME]]([[VIEW]]) : $@convention(thin) (@owned View) -> ()
126+
// CHECK: end_access [[BA]] : $*NCContainer
127+
// CHECK-LABEL: } // end sil function '$s31lifetime_dependence_scope_fixup5test2yySaySiGFySWXEfU_'
115128
func test2(_ a: Array<Int>) {
116129
a.withUnsafeBytes {
117130
var x = NCContainer($0, a.count)
@@ -166,6 +179,18 @@ func test6(_ a: Array<Int>) {
166179
use(p!)
167180
}
168181

182+
// CHECK-LABEL: sil hidden @$s31lifetime_dependence_scope_fixup5test7yySWF : $@convention(thin) (UnsafeRawBufferPointer) -> () {
183+
// CHECK: [[CONT:%.*]] = alloc_stack $NEContainer, var, name "x"
184+
// CHECK: [[BA:%.*]] = begin_access [read] [static] [[CONT]] : $*NEContainer
185+
// CHECK: [[LD:%.*]] = load [[BA]] : $*NEContainer
186+
// CHECK: [[FUNC:%.*]] = function_ref @$s31lifetime_dependence_scope_fixup16getBorrowingViewyAA0G0VAA11NEContainerVYlsF : $@convention(thin) (@guaranteed NEContainer) -> _scope(1) @owned View
187+
// CHECK: [[VIEW:%.*]] = apply [[FUNC]]([[LD]]) : $@convention(thin) (@guaranteed NEContainer) -> _scope(1) @owned View
188+
// CHECK: [[MDI:%.*]] = mark_dependence [nonescaping] [[VIEW]] : $View on [[BA]] : $*NEContainer
189+
// CHECK: [[USE:%.*]] = function_ref @$s31lifetime_dependence_scope_fixup3useyyAA4ViewVF : $@convention(thin) (@guaranteed View) -> ()
190+
// CHECK: apply [[USE]]([[MDI]]) : $@convention(thin) (@guaranteed View) -> ()
191+
// CHECK: release_value [[MDI]] : $View
192+
// CHECK: end_access [[BA]] : $*NEContainer
193+
// CHECK-LABEL: } // end sil function '$s31lifetime_dependence_scope_fixup5test7yySWF'
169194
func test7(_ a: UnsafeRawBufferPointer) {
170195
var x = NEContainer(a, a.count)
171196
do {

0 commit comments

Comments
 (0)