@@ -12,12 +12,42 @@ sil [_semantics "sequence.forEach"] @forEach : $@convention(method) <τ_0_0 wher
12
12
13
13
sil @forEachBody : $@convention(thin) (@in_guaranteed Builtin.Int64) -> @error any Error
14
14
15
+ // CHECK-LABEL: forEachLoopUnrollTest
16
+ // CHECK: [[LIT1:%[0-9]+]] = integer_literal $Builtin.Int64, 15
17
+ // CHECK: [[LIT2:%[0-9]+]] = integer_literal $Builtin.Int64, 27
18
+ // CHECK: [[BODYCLOSURE:%[0-9]+]] = thin_to_thick_function
19
+ // CHECK-NOT: forEach
20
+ // CHECK: [[STACK:%[0-9]+]] = alloc_stack $Builtin.Int64
21
+ // CHECK: store [[LIT1]] to [trivial] [[STACK]]
22
+ // CHECK: try_apply [[BODYCLOSURE]]([[STACK]]) : $@noescape @callee_guaranteed (@in_guaranteed Builtin.Int64) -> @error any Error, normal [[NORMAL:bb[0-9]+]], error [[ERROR:bb[0-9]+]]
23
+
24
+ // CHECK: [[ERROR]]([[ERRPARAM:%[0-9]+]] : @owned $any Error):
25
+ // CHECK: br [[ERROR3:bb[0-9]+]]([[ERRPARAM]] : $any Error)
26
+
27
+ // CHECK: [[NORMAL]](%{{.*}} : $()):
28
+ // CHECK: store [[LIT2]] to [trivial] [[STACK]] : $*Builtin.Int64
29
+ // CHECK: try_apply [[BODYCLOSURE]]([[STACK]]) : $@noescape @callee_guaranteed (@in_guaranteed Builtin.Int64) -> @error any Error, normal [[NORMAL2:bb[0-9]+]], error [[ERROR2:bb[0-9]+]]
30
+
31
+ // CHECK: [[ERROR2]]([[ERRPARAM2:%[0-9]+]] : @owned $any Error):
32
+ // CHECK: br [[ERROR3:bb[0-9]+]]([[ERRPARAM2]] : $any Error)
33
+
34
+ // CHECK: [[NORMAL2]](%{{.*}} : $()):
35
+ // CHECK: dealloc_stack [[STACK]]
36
+ // Note that the temporary alloc_stack of the array created for the forEach call
37
+ // will be cleaned up when the forEach call is removed.
38
+ // CHECK: destroy_value
39
+
40
+ // CHECK: [[ERROR3]]([[ERRPARAM3:%[0-9]+]] : @owned $any Error):
41
+ // CHECK: dealloc_stack [[STACK]]
42
+ // CHECK: unreachable
43
+
15
44
sil hidden [ossa] @forEachLoopUnrollTest : $@convention(thin) () -> () {
16
45
bb0:
17
46
%0 = integer_literal $Builtin.Word, 2
18
47
%1 = function_ref @_allocateUninitializedArray : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
19
48
%2 = apply %1<Builtin.Int64>(%0) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
20
- (%3, %4) = destructure_tuple %2 : $(Array<Builtin.Int64>, Builtin.RawPointer)
49
+ (%3, %4a) = destructure_tuple %2 : $(Array<Builtin.Int64>, Builtin.RawPointer)
50
+ %4 = mark_dependence %4a : $Builtin.RawPointer on %3 : $Array<Builtin.Int64>
21
51
%5 = pointer_to_address %4 : $Builtin.RawPointer to [strict] $*Builtin.Int64
22
52
%6 = integer_literal $Builtin.Int64, 15
23
53
store %6 to [trivial] %5 : $*Builtin.Int64
@@ -46,26 +76,35 @@ bb1(%32 : $()):
46
76
bb2(%39 : @owned $Error):
47
77
unreachable
48
78
}
49
- // CHECK-LABEL: forEachLoopUnrollTest
50
- // CHECK: [[LIT1:%[0-9]+]] = integer_literal $Builtin.Int64, 15
51
- // CHECK: [[LIT2:%[0-9]+]] = integer_literal $Builtin.Int64, 27
79
+
80
+ sil @forEachBody2 : $@convention(thin) (@in_guaranteed @callee_guaranteed @substituted <A> () -> @out A for <Int>) -> @error any Error
81
+
82
+ // CHECK-LABEL: nonTrivialForEachLoopUnrollTest
83
+ // CHECK: [[ELEM1:%[0-9]+]] = copy_value %0
84
+ // CHECK-NEXT: store %0 to [init] %{{.*}} : $*@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>
85
+ // CHECK: [[ELEM2:%[0-9]+]] = copy_value %1
86
+ // CHECK-NEXT: store %1 to [init] %{{.*}} : $*@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>
52
87
// CHECK: [[BODYCLOSURE:%[0-9]+]] = thin_to_thick_function
53
88
// CHECK-NOT: forEach
54
- // CHECK: [[STACK:%[0-9]+]] = alloc_stack $Builtin.Int64
55
- // CHECK: store [[LIT1]] to [trivial] [[STACK]]
56
- // CHECK: try_apply [[BODYCLOSURE]]([[STACK]]) : $@noescape @callee_guaranteed (@in_guaranteed Builtin.Int64) -> @error any Error, normal [[NORMAL:bb[0-9]+]], error [[ERROR:bb[0-9]+]]
89
+ // CHECK: [[STACK:%[0-9]+]] = alloc_stack $@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>
90
+ // CHECK: [[ELEM1BORROW:%[0-9]+]] = begin_borrow [[ELEM1]]
91
+ // CHECK: [[SB1:%.*]] = store_borrow [[ELEM1BORROW]] to [[STACK]]
92
+ // CHECK: try_apply [[BODYCLOSURE]]([[SB1]]) : $@noescape @callee_guaranteed (@in_guaranteed @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>) -> @error any Error, normal [[NORMAL:bb[0-9]+]], error [[ERROR:bb[0-9]+]]
57
93
58
94
// CHECK: [[ERROR]]([[ERRPARAM:%[0-9]+]] : @owned $any Error):
59
95
// CHECK: br [[ERROR3:bb[0-9]+]]([[ERRPARAM]] : $any Error)
60
96
61
97
// CHECK: [[NORMAL]](%{{.*}} : $()):
62
- // CHECK: store [[LIT2]] to [trivial] [[STACK]] : $*Builtin.Int64
63
- // CHECK: try_apply [[BODYCLOSURE]]([[STACK]]) : $@noescape @callee_guaranteed (@in_guaranteed Builtin.Int64) -> @error any Error, normal [[NORMAL2:bb[0-9]+]], error [[ERROR2:bb[0-9]+]]
98
+ // CHECK: end_borrow [[ELEM1BORROW]]
99
+ // CHECK: [[ELEM2BORROW:%[0-9]+]] = begin_borrow [[ELEM2]]
100
+ // CHECK: [[SB2:%.*]] = store_borrow [[ELEM2BORROW]] to [[STACK]]
101
+ // CHECK: try_apply [[BODYCLOSURE]]([[SB2]]) : $@noescape @callee_guaranteed (@in_guaranteed @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>) -> @error any Error, normal [[NORMAL2:bb[0-9]+]], error [[ERROR2:bb[0-9]+]]
64
102
65
103
// CHECK: [[ERROR2]]([[ERRPARAM2:%[0-9]+]] : @owned $any Error):
66
104
// CHECK: br [[ERROR3:bb[0-9]+]]([[ERRPARAM2]] : $any Error)
67
105
68
106
// CHECK: [[NORMAL2]](%{{.*}} : $()):
107
+ // CHECK: end_borrow [[ELEM2BORROW]]
69
108
// CHECK: dealloc_stack [[STACK]]
70
109
// Note that the temporary alloc_stack of the array created for the forEach call
71
110
// will be cleaned up when the forEach call is removed.
@@ -74,15 +113,13 @@ bb2(%39 : @owned $Error):
74
113
// CHECK: [[ERROR3]]([[ERRPARAM3:%[0-9]+]] : @owned $any Error):
75
114
// CHECK: dealloc_stack [[STACK]]
76
115
// CHECK: unreachable
77
-
78
- sil @forEachBody2 : $@convention(thin) (@in_guaranteed @callee_guaranteed @substituted <A> () -> @out A for <Int>) -> @error any Error
79
-
80
116
sil hidden [ossa] @nonTrivialForEachLoopUnrollTest : $@convention(thin) (@owned @callee_guaranteed @substituted <A> () -> @out A for <Int>, @owned @callee_guaranteed @substituted <A> () -> @out A for <Int>) -> () {
81
117
bb0(%0: @owned $@callee_guaranteed @substituted <A> () -> @out A for <Int>, %1: @owned $@callee_guaranteed @substituted <A> () -> @out A for <Int>):
82
118
%2 = integer_literal $Builtin.Word, 2
83
119
%3 = function_ref @_allocateUninitializedArray : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
84
120
%4 = apply %3<() -> Int>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
85
- (%5, %6) = destructure_tuple %4 : $(Array<()->Int>, Builtin.RawPointer)
121
+ (%5, %6a) = destructure_tuple %4 : $(Array<()->Int>, Builtin.RawPointer)
122
+ %6 = mark_dependence %6a : $Builtin.RawPointer on %5 : $Array<() -> Int>
86
123
%7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*@callee_guaranteed @substituted <A> () -> @out A for <Int>
87
124
store %0 to [init] %7 : $*@callee_guaranteed @substituted <A> () -> @out A for <Int>
88
125
%12 = integer_literal $Builtin.Word, 1
@@ -109,47 +146,17 @@ bb1(%32 : $()):
109
146
bb2(%39 : @owned $Error):
110
147
unreachable
111
148
}
112
- // CHECK-LABEL: nonTrivialForEachLoopUnrollTest
113
- // CHECK: [[ELEM1:%[0-9]+]] = copy_value %0
114
- // CHECK-NEXT: store %0 to [init] %{{.*}} : $*@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>
115
- // CHECK: [[ELEM2:%[0-9]+]] = copy_value %1
116
- // CHECK-NEXT: store %1 to [init] %{{.*}} : $*@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>
117
- // CHECK: [[BODYCLOSURE:%[0-9]+]] = thin_to_thick_function
118
- // CHECK-NOT: forEach
119
- // CHECK: [[STACK:%[0-9]+]] = alloc_stack $@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>
120
- // CHECK: [[ELEM1BORROW:%[0-9]+]] = begin_borrow [[ELEM1]]
121
- // CHECK: [[SB1:%.*]] = store_borrow [[ELEM1BORROW]] to [[STACK]]
122
- // CHECK: try_apply [[BODYCLOSURE]]([[SB1]]) : $@noescape @callee_guaranteed (@in_guaranteed @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>) -> @error any Error, normal [[NORMAL:bb[0-9]+]], error [[ERROR:bb[0-9]+]]
123
-
124
- // CHECK: [[ERROR]]([[ERRPARAM:%[0-9]+]] : @owned $any Error):
125
- // CHECK: br [[ERROR3:bb[0-9]+]]([[ERRPARAM]] : $any Error)
126
-
127
- // CHECK: [[NORMAL]](%{{.*}} : $()):
128
- // CHECK: end_borrow [[ELEM1BORROW]]
129
- // CHECK: [[ELEM2BORROW:%[0-9]+]] = begin_borrow [[ELEM2]]
130
- // CHECK: [[SB2:%.*]] = store_borrow [[ELEM2BORROW]] to [[STACK]]
131
- // CHECK: try_apply [[BODYCLOSURE]]([[SB2]]) : $@noescape @callee_guaranteed (@in_guaranteed @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Int>) -> @error any Error, normal [[NORMAL2:bb[0-9]+]], error [[ERROR2:bb[0-9]+]]
132
-
133
- // CHECK: [[ERROR2]]([[ERRPARAM2:%[0-9]+]] : @owned $any Error):
134
- // CHECK: br [[ERROR3:bb[0-9]+]]([[ERRPARAM2]] : $any Error)
135
-
136
- // CHECK: [[NORMAL2]](%{{.*}} : $()):
137
- // CHECK: end_borrow [[ELEM2BORROW]]
138
- // CHECK: dealloc_stack [[STACK]]
139
- // Note that the temporary alloc_stack of the array created for the forEach call
140
- // will be cleaned up when the forEach call is removed.
141
- // CHECK: destroy_value
142
-
143
- // CHECK: [[ERROR3]]([[ERRPARAM3:%[0-9]+]] : @owned $any Error):
144
- // CHECK: dealloc_stack [[STACK]]
145
- // CHECK: unreachable
146
149
150
+ // CHECK-LABEL: @checkIndirectFixLifetimeUsesAreIgnored
151
+ // CHECK-NOT: function_ref @forEach : $@convention(method) <τ_0_0 where τ_0_0 : Sequence> (@noescape @callee_guaranteed (@in_guaranteed τ_0_0.Element) -> @error any Error, @in_guaranteed τ_0_0) -> @error any Error
152
+ // CHECK: end sil function 'checkIndirectFixLifetimeUsesAreIgnored'
147
153
sil hidden [ossa] @checkIndirectFixLifetimeUsesAreIgnored : $@convention(thin) () -> () {
148
154
bb0:
149
155
%0 = integer_literal $Builtin.Word, 2
150
156
%1 = function_ref @_allocateUninitializedArray : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
151
157
%2 = apply %1<Builtin.Int64>(%0) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
152
- (%3, %4) = destructure_tuple %2 : $(Array<Builtin.Int64>, Builtin.RawPointer)
158
+ (%3, %4a) = destructure_tuple %2 : $(Array<Builtin.Int64>, Builtin.RawPointer)
159
+ %4 = mark_dependence %4a : $Builtin.RawPointer on %3 : $Array<Builtin.Int64>
153
160
%5 = pointer_to_address %4 : $Builtin.RawPointer to [strict] $*Builtin.Int64
154
161
%6 = integer_literal $Builtin.Int64, 15
155
162
store %6 to [trivial] %5 : $*Builtin.Int64
@@ -184,10 +191,10 @@ bb1(%32 : $()):
184
191
bb2(%39 : @owned $Error):
185
192
unreachable
186
193
}
187
- // CHECK-LABEL: @checkIndirectFixLifetimeUsesAreIgnored
188
- // CHECK-NOT: function_ref @forEach : $@convention(method) <τ_0_0 where τ_0_0 : Sequence> (@noescape @callee_guaranteed (@in_guaranteed τ_0_0.Element) -> @error any Error, @in_guaranteed τ_0_0) -> @error any Error
189
- // CHECK: end sil function 'checkIndirectFixLifetimeUsesAreIgnored'
190
194
195
+ // CHECK-LABEL: @testUnrollOfArrayWithPhiArguments
196
+ // CHECK-NOT: function_ref @forEach : $@convention(method) <τ_0_0 where τ_0_0 : Sequence> (@noescape @callee_guaranteed (@in_guaranteed τ_0_0.Element) -> @error any Error, @in_guaranteed τ_0_0) -> @error any Error
197
+ // CHECK: end sil function 'testUnrollOfArrayWithPhiArguments'
191
198
sil hidden [ossa] @testUnrollOfArrayWithPhiArguments : $@convention(thin) () -> () {
192
199
bb0:
193
200
%0 = integer_literal $Builtin.Int64, 57
@@ -197,7 +204,8 @@ bb1(%arg : $Builtin.Int64):
197
204
%10 = integer_literal $Builtin.Word, 1
198
205
%11 = function_ref @_allocateUninitializedArray : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
199
206
%12 = apply %11<Builtin.Int64>(%10) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
200
- (%13, %14) = destructure_tuple %12 : $(Array<Builtin.Int64>, Builtin.RawPointer)
207
+ (%13, %14a) = destructure_tuple %12 : $(Array<Builtin.Int64>, Builtin.RawPointer)
208
+ %14 = mark_dependence %14a : $Builtin.RawPointer on %13 : $Array<Builtin.Int64>
201
209
%15 = pointer_to_address %14 : $Builtin.RawPointer to [strict] $*Builtin.Int64
202
210
store %arg to [trivial] %15 : $*Builtin.Int64
203
211
br bb2(%arg : $Builtin.Int64)
@@ -224,7 +232,4 @@ bb3(%32 : $()):
224
232
bb4(%39 : @owned $Error):
225
233
unreachable
226
234
}
227
- // CHECK-LABEL: @testUnrollOfArrayWithPhiArguments
228
- // CHECK-NOT: function_ref @forEach : $@convention(method) <τ_0_0 where τ_0_0 : Sequence> (@noescape @callee_guaranteed (@in_guaranteed τ_0_0.Element) -> @error any Error, @in_guaranteed τ_0_0) -> @error any Error
229
- // CHECK: end sil function 'testUnrollOfArrayWithPhiArguments'
230
235
0 commit comments