@@ -9,19 +9,23 @@ struct State {
9
9
@TestWrapper var values : [ String ] = [ ]
10
10
}
11
11
12
- var state = State ( )
13
- state. values = Array ( repeating: " " , count: 20000 )
12
+ protocol StateProtocol {
13
+ @_borrowed var someValues : [ String ] { get set }
14
+ }
14
15
15
- for i in 0 ..< 20000 {
16
- // CHECK: bb3([[INDEX:%.*]] : $Int):
17
- // CHECK: [[BEGIN_ACCESS_MODIFY:%.*]] = begin_access [modify] [dynamic] {{%.*}} : $*State
18
- // CHECK: [[REF_MODIFY:%.*]] = function_ref @$s26property_wrapper_coroutine5StateV6valuesSaySSGvM : $@yield_once @convention(method) (@inout State) -> @yields @inout Array<String>
19
- // CHECK: ([[RES1:%.*]], {{%.*}}) = begin_apply [[REF_MODIFY]]([[BEGIN_ACCESS_MODIFY]]) : $@yield_once @convention(method) (@inout State) -> @yields @inout Array<String>
20
- // CHECK: [[REF_ARRAY_SUBSCRIPT:%.*]] = function_ref @$sSayxSiciM : $@yield_once @convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> @yields @inout τ_0_0
21
- // CHECK: ({{%.*}}, {{%.*}}) = begin_apply [[REF_ARRAY_SUBSCRIPT]]<String>([[INDEX]], [[RES1]]) : $@yield_once @convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> @yields @inout τ_0_0
22
- state. values [ i] = String ( i)
16
+ struct State1 : StateProtocol {
17
+ @TestWrapper var someValues : [ String ] = [ ]
23
18
}
24
19
20
+ var state = State ( )
21
+ state. values = Array ( repeating: " " , count: 20000 )
22
+ // CHECK: [[BEGIN_ACCESS_MODIFY:%.*]] = begin_access [modify] [dynamic] {{%.*}} : $*State
23
+ // CHECK: [[REF_MODIFY:%.*]] = function_ref @$s26property_wrapper_coroutine5StateV6valuesSaySSGvM : $@yield_once @convention(method) (@inout State) -> @yields @inout Array<String>
24
+ // CHECK: ([[RES1:%.*]], {{%.*}}) = begin_apply [[REF_MODIFY]]([[BEGIN_ACCESS_MODIFY]]) : $@yield_once @convention(method) (@inout State) -> @yields @inout Array<String>
25
+ // CHECK: [[REF_ARRAY_SUBSCRIPT:%.*]] = function_ref @$sSayxSiciM : $@yield_once @convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> @yields @inout τ_0_0
26
+ // CHECK: ({{%.*}}, {{%.*}}) = begin_apply [[REF_ARRAY_SUBSCRIPT]]<String>({{%.*}}, [[RES1]]) : $@yield_once @convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> @yields @inout τ_0_0
27
+ state. values [ 1000 ] = " foo "
28
+
25
29
// CHECK-LABEL: sil hidden [transparent] [ossa] @$s26property_wrapper_coroutine5StateV6valuesSaySSGvM : $@yield_once @convention(method) (@inout State) -> @yields @inout Array<String> {
26
30
// CHECK: bb0([[STATE:%.*]] : $*State):
27
31
// CHECK: debug_value_addr [[STATE]] : $*State, var, name "self", argno {{.*}}
@@ -39,3 +43,27 @@ for i in 0..<20000 {
39
43
// CHECK: end_access [[BEGIN_ACCESS]] : $*State
40
44
// CHECK: unwind
41
45
// CHECK-END: }
46
+
47
+ var state1 = State1 ( )
48
+ _ = state1. someValues
49
+
50
+ // CHECK-LABEL: sil shared [ossa] @$s26property_wrapper_coroutine6State1V10someValuesSaySSGvr : $@yield_once @convention(method) (@guaranteed State1) -> @yields @guaranteed Array<String> {
51
+ // CHECK: bb0([[STATE1:%.*]] : @guaranteed $State1):
52
+ // CHECK: debug_value [[SELF:%.*]] : $State1, let, name "self", argno {{.*}}
53
+ // CHECK: [[EXTRACT_VALUE:%.*]] = struct_extract %0 : $State1, #State1._someValues
54
+ // CHECK: [[COPY_VALUE:%.*]] = copy_value [[EXTRACT_VALUE]] : $TestWrapper<Array<String>>
55
+ // CHECK: [[BEGIN_BORROW:%.*]] = begin_borrow [[COPY]] : $TestWrapper<Array<String>>
56
+ // CHECK: [[EXTRACT_WRAPPEDVALUE:%.*]] = struct_extract [[BEGIN_BORROW]] : $TestWrapper<Array<String>>, #TestWrapper.wrappedValue
57
+ // CHECK: yield [[EXTRACT_WRAPPEDVALUE]] : $Array<String>, resume bb1, unwind bb2
58
+ //
59
+ // CHECK: bb1:
60
+ // CHECK: end_borrow [[BEGIN_BORROW]] : $TestWrapper<Array<String>>
61
+ // CHECK: destroy_value [[COPY_VALUE]] : $TestWrapper<Array<String>>
62
+ // CHECK: [[RETURN:%.*]] = tuple ()
63
+ // CHECK: return [[RETURN]] : $()
64
+ //
65
+ // CHECK: bb2:
66
+ // CHECK: end_borrow [[BEGIN_BORROW]] : $TestWrapper<Array<String>>
67
+ // CHECK: destroy_value [[COPY_VALUE]] : $TestWrapper<Array<String>>
68
+ // CHECK: unwind
69
+ // CHECK-END: }
0 commit comments