1- // RUN: %target-sil-opt %s -onone-simplification -simplify-instruction=mark_dependence -enable-experimental-feature LifetimeDependence | %FileCheck %s
1+ // RUN: %target-sil-opt %s -onone-simplification -simplify-instruction=mark_dependence -enable-experimental-feature Lifetimes | %FileCheck %s
22
3- // REQUIRES: swift_feature_LifetimeDependence
3+ // REQUIRES: swift_feature_Lifetimes
44
55import Swift
66import Builtin
@@ -14,10 +14,20 @@ struct S {
1414
1515struct NE: ~Escapable {}
1616
17+ struct NEHolder : ~Escapable {
18+ var ne: NE {
19+ @_lifetime(borrow self)
20+ get
21+ }
22+ }
23+
1724struct S2: ~Escapable {
1825 var a: NE
1926}
2027
28+ sil @read_ne : $@yield_once @convention(method) (@guaranteed NEHolder) -> @lifetime(borrow 0) @yields @guaranteed NE
29+ sil @use_ne : $@convention(thin) (@guaranteed NE) -> ()
30+
2131// CHECK-LABEL: sil [ossa] @mark_dependence_trivial_base :
2232// CHECK: %2 = copy_value %0
2333// CHECK-NEXT: return %2
@@ -155,3 +165,26 @@ bb0(%0 : $*Builtin.Int64, %1 : $B):
155165 return %5
156166}
157167
168+ // CHECK-LABEL: sil hidden [ossa] @testChainedDependence : $@convention(thin) (@guaranteed NEHolder) -> () {
169+ // CHECK: bb0(%0 : @noImplicitCopy @guaranteed $NEHolder):
170+ // CHECK: ([[YIELD:%[0-9]+]], [[TOKEN:%[0-9]+]]) = begin_apply %{{.*}}(%{{.*}}) : $@yield_once @convention(method) (@guaranteed NEHolder) -> @lifetime(borrow 0) @yields @guaranteed NE
171+ // CHECK: [[MD1:%[0-9]+]] = mark_dependence [nonescaping] [[YIELD]] on [[TOKEN]]
172+ // CHECK: mark_dependence [nonescaping] [[MD1]] on
173+ // CHECK-LABEL: } // end sil function 'testChainedDependence'
174+ sil hidden [ossa] @testChainedDependence : $@convention(thin) (@guaranteed NEHolder) -> () {
175+ bb0(%0 : @noImplicitCopy @guaranteed $NEHolder):
176+ %2 = begin_borrow %0
177+ %3 = function_ref @read_ne : $@yield_once @convention(method) (@guaranteed NEHolder) -> @lifetime(borrow 0) @yields @guaranteed NE
178+ (%4, %5) = begin_apply %3(%2) : $@yield_once @convention(method) (@guaranteed NEHolder) -> @lifetime(borrow 0) @yields @guaranteed NE
179+ %6 = mark_dependence [nonescaping] %4 on %5
180+ %7 = mark_dependence [nonescaping] %6 on %2
181+ %8 = copy_value %7
182+ %9 = move_value [var_decl] %8
183+ %11 = function_ref @use_ne : $@convention(thin) (@guaranteed NE) -> ()
184+ %12 = apply %11(%9) : $@convention(thin) (@guaranteed NE) -> ()
185+ destroy_value %9
186+ %14 = end_apply %5 as $()
187+ end_borrow %2
188+ %16 = tuple ()
189+ return %16
190+ }
0 commit comments