1
- // RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -sil-combine -sil-combine-disable-alloc-stack-opts | %FileCheck %s
1
+ // RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -sil-combine -sil-combine-disable-alloc-stack-opts -enable-experimental-feature Lifetimes | %FileCheck %s
2
2
3
3
// REQUIRES: swift_in_compiler
4
+ // REQUIRES: swift_feature_Lifetimes
4
5
5
6
import Swift
6
7
import Builtin
@@ -27,6 +28,18 @@ protocol FakeProtocol {
27
28
func requirement()
28
29
}
29
30
31
+ struct NE: ~Escapable {}
32
+
33
+ struct NEHolder : ~Escapable {
34
+ var ne: NE {
35
+ @_lifetime(borrow self)
36
+ get
37
+ }
38
+ }
39
+
40
+ sil @read_ne : $@yield_once @convention(method) (@guaranteed NEHolder) -> @lifetime(borrow 0) @yields @guaranteed NE
41
+ sil @use_ne : $@convention(thin) (@guaranteed NE) -> ()
42
+
30
43
/////////////////////////////////
31
44
// Tests for SILCombinerApply. //
32
45
/////////////////////////////////
@@ -1019,3 +1032,27 @@ bb3:
1019
1032
%rv = tuple()
1020
1033
return %rv : $()
1021
1034
}
1035
+
1036
+ // CHECK-LABEL: sil hidden [ossa] @testChainedDependence : $@convention(thin) (@guaranteed NEHolder) -> () {
1037
+ // CHECK: bb0(%0 : @noImplicitCopy @guaranteed $NEHolder):
1038
+ // CHECK: ([[YIELD:%[0-9]+]], [[TOKEN:%[0-9]+]]) = begin_apply %{{.*}}(%{{.*}}) : $@yield_once @convention(method) (@guaranteed NEHolder) -> @lifetime(borrow 0) @yields @guaranteed NE
1039
+ // CHECK: [[MD1:%[0-9]+]] = mark_dependence [nonescaping] [[YIELD]] : $NE on [[TOKEN]]
1040
+ // CHECK: mark_dependence [nonescaping] [[MD1]]
1041
+ // CHECK-LABEL: } // end sil function 'testChainedDependence'
1042
+ sil hidden [ossa] @testChainedDependence : $@convention(thin) (@guaranteed NEHolder) -> () {
1043
+ bb0(%0 : @noImplicitCopy @guaranteed $NEHolder):
1044
+ %2 = begin_borrow %0
1045
+ %3 = function_ref @read_ne : $@yield_once @convention(method) (@guaranteed NEHolder) -> @lifetime(borrow 0) @yields @guaranteed NE
1046
+ (%4, %5) = begin_apply %3(%2) : $@yield_once @convention(method) (@guaranteed NEHolder) -> @lifetime(borrow 0) @yields @guaranteed NE
1047
+ %6 = mark_dependence [nonescaping] %4 on %5
1048
+ %7 = mark_dependence [nonescaping] %6 on %2
1049
+ %8 = copy_value %7
1050
+ %9 = move_value [var_decl] %8
1051
+ %11 = function_ref @use_ne : $@convention(thin) (@guaranteed NE) -> ()
1052
+ %12 = apply %11(%9) : $@convention(thin) (@guaranteed NE) -> ()
1053
+ destroy_value %9
1054
+ %14 = end_apply %5 as $()
1055
+ end_borrow %2
1056
+ %16 = tuple ()
1057
+ return %16
1058
+ }
0 commit comments