Skip to content

Commit 42473e3

Browse files
committed
[Test] Update test to check for _read coroutine as well
1 parent 47ba176 commit 42473e3

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

test/SILGen/property_wrapper_coroutine.swift

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,23 @@ struct State {
99
@TestWrapper var values: [String] = []
1010
}
1111

12-
var state = State()
13-
state.values = Array(repeating: "", count: 20000)
12+
protocol StateProtocol {
13+
@_borrowed var someValues: [String] { get set }
14+
}
1415

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] = []
2318
}
2419

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+
2529
// CHECK-LABEL: sil hidden [transparent] [ossa] @$s26property_wrapper_coroutine5StateV6valuesSaySSGvM : $@yield_once @convention(method) (@inout State) -> @yields @inout Array<String> {
2630
// CHECK: bb0([[STATE:%.*]] : $*State):
2731
// CHECK: debug_value_addr [[STATE]] : $*State, var, name "self", argno {{.*}}
@@ -39,3 +43,27 @@ for i in 0..<20000 {
3943
// CHECK: end_access [[BEGIN_ACCESS]] : $*State
4044
// CHECK: unwind
4145
// 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

Comments
 (0)