Skip to content

Commit 1c2ba06

Browse files
authored
Merge pull request #9993 from swiftix/closure-specializer-improvements3
Fix the test to use only fixed size integer types
2 parents ee4293f + 2108d7e commit 1c2ba06

File tree

1 file changed

+65
-65
lines changed

1 file changed

+65
-65
lines changed

test/SILOptimizer/closure_specialize_consolidated.sil

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public struct S {
4545
// @in_guaranteed.
4646
// (*NOTE* this includes address and non-address only types).
4747
// This is a temporary limitation.
48-
// CHECK-LABEL: sil @address_closure : $@convention(thin) (@in Int) -> () {
49-
sil @address_closure : $@convention(thin) (@in Int) -> () {
50-
bb0(%0 : $*Int):
48+
// CHECK-LABEL: sil @address_closure : $@convention(thin) (@in Int32) -> () {
49+
sil @address_closure : $@convention(thin) (@in Int32) -> () {
50+
bb0(%0 : $*Int32):
5151
%6 = tuple()
5252
return %6 : $()
5353
}
@@ -60,17 +60,17 @@ bb0(%0 : $*S):
6060

6161
// Check that a specialization of address_closure_user was generated which does not
6262
// take a closure as a parameter anymore.
63-
// CHECK-LABEL: sil shared @{{.*}}address_closure_user{{.*}} : $@convention(thin) (Int64, @inout_aliasable Int64) -> ()
64-
// CHECK: function_ref @address_closure_trivial : $@convention(thin) (Int64, @inout_aliasable Int64) -> ()
65-
// CHECK: partial_apply %{{.*}} : $@convention(thin) (Int64, @inout_aliasable Int64) -> ()
63+
// CHECK-LABEL: sil shared @{{.*}}address_closure_user{{.*}} : $@convention(thin) (Int32, @inout_aliasable Int32) -> ()
64+
// CHECK: function_ref @address_closure_trivial : $@convention(thin) (Int32, @inout_aliasable Int32) -> ()
65+
// CHECK: partial_apply %{{.*}} : $@convention(thin) (Int32, @inout_aliasable Int32) -> ()
6666
// CHECK: apply
6767
// CHECK: return
6868

6969
// Check that a specialization of address_closure_user was generated which does not
7070
// take a closure as a parameter anymore.
71-
// CHECK-LABEL: sil shared @{{.*}}address_closure_user{{.*}} : $@convention(thin) (@inout_aliasable Int64) -> ()
72-
// CHECK: function_ref @address_closure_trivial_mutating : $@convention(thin) (@inout_aliasable Int64) -> ()
73-
// CHECK: partial_apply %{{.*}} : $@convention(thin) (@inout_aliasable Int64) -> ()
71+
// CHECK-LABEL: sil shared @{{.*}}address_closure_user{{.*}} : $@convention(thin) (@inout_aliasable Int32) -> ()
72+
// CHECK: function_ref @address_closure_trivial_mutating : $@convention(thin) (@inout_aliasable Int32) -> ()
73+
// CHECK: partial_apply %{{.*}} : $@convention(thin) (@inout_aliasable Int32) -> ()
7474
// CHECK: apply
7575
// CHECK: return
7676

@@ -114,12 +114,12 @@ bb0(%0 : $@callee_owned () -> ()):
114114
return %9999 : $()
115115
}
116116

117-
// CHECK-LABEL: sil @address_caller : $@convention(thin) (@in Int) -> () {
117+
// CHECK-LABEL: sil @address_caller : $@convention(thin) (@in Int32) -> () {
118118
// CHECK-NOT: _TTSf1cl15address_closureSi__address_closure_user
119-
sil @address_caller : $@convention(thin) (@in Int) -> () {
120-
bb0(%0 : $*Int):
121-
%1 = function_ref @address_closure : $@convention(thin) (@in Int) -> ()
122-
%2 = partial_apply %1(%0) : $@convention(thin) (@in Int) -> ()
119+
sil @address_caller : $@convention(thin) (@in Int32) -> () {
120+
bb0(%0 : $*Int32):
121+
%1 = function_ref @address_closure : $@convention(thin) (@in Int32) -> ()
122+
%2 = partial_apply %1(%0) : $@convention(thin) (@in Int32) -> ()
123123
%3 = function_ref @address_closure_user : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
124124
%4 = apply %3(%2) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
125125
%9999 = tuple()
@@ -131,21 +131,21 @@ bb0(%0 : $*Int):
131131
// (*NOTE* this includes address and non-address only types).
132132
// This is a temporary limitation.
133133
//
134-
// CHECK-LABEL: sil @address_caller_complex : $@convention(thin) (@in Int) -> ()
135-
// CHECK-NOT: function_ref @{{.*}}address_closure_user{{.*}} : $@convention(thin) (@in Int) -> ()
134+
// CHECK-LABEL: sil @address_caller_complex : $@convention(thin) (@in Int32) -> ()
135+
// CHECK-NOT: function_ref @{{.*}}address_closure_user{{.*}} : $@convention(thin) (@in Int32) -> ()
136136
// CHECK: partial_apply
137-
// CHECK-NOT: function_ref @{{.*}}address_closure_user{{.*}} : $@convention(thin) (@in Int) -> ()
137+
// CHECK-NOT: function_ref @{{.*}}address_closure_user{{.*}} : $@convention(thin) (@in Int32) -> ()
138138
// CHECK: return
139-
sil @address_caller_complex : $@convention(thin) (@in Int) -> () {
140-
bb0(%0 : $*Int):
141-
%00 = alloc_stack $Int
142-
%01 = load %0 : $*Int
143-
store %01 to %00 : $*Int
144-
%1 = function_ref @address_closure : $@convention(thin) (@in Int) -> ()
145-
%2 = partial_apply %1(%00) : $@convention(thin) (@in Int) -> ()
139+
sil @address_caller_complex : $@convention(thin) (@in Int32) -> () {
140+
bb0(%0 : $*Int32):
141+
%00 = alloc_stack $Int32
142+
%01 = load %0 : $*Int32
143+
store %01 to %00 : $*Int32
144+
%1 = function_ref @address_closure : $@convention(thin) (@in Int32) -> ()
145+
%2 = partial_apply %1(%00) : $@convention(thin) (@in Int32) -> ()
146146
%3 = function_ref @address_closure_user : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
147147
%4 = apply %3(%2) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
148-
dealloc_stack %00 : $*Int
148+
dealloc_stack %00 : $*Int32
149149
br bb1
150150

151151
bb1:
@@ -187,69 +187,69 @@ bb1:
187187

188188
// More complex tests involving address arguments.
189189

190-
sil @address_closure_trivial : $@convention(thin) (Int64, @inout_aliasable Int64) -> () {
191-
bb0(%0 : $Int64, %1 : $*Int64):
192-
%9 = integer_literal $Builtin.Int64, 42
193-
%10 = struct $Int64 (%9 : $Builtin.Int64)
194-
store %10 to %1 : $*Int64
190+
sil @address_closure_trivial : $@convention(thin) (Int32, @inout_aliasable Int32) -> () {
191+
bb0(%0 : $Int32, %1 : $*Int32):
192+
%9 = integer_literal $Builtin.Int32, 42
193+
%10 = struct $Int32 (%9 : $Builtin.Int32)
194+
store %10 to %1 : $*Int32
195195
%12 = tuple ()
196196
return %12 : $()
197197
}
198198

199199
// CHECK-LABEL: sil @address_caller_trivial
200200
// CHECK-NOT: partial_apply
201-
// CHECK: [[SPECIALIZED_FN1:%.*]] = function_ref @{{.*}}address_closure_user{{.*}} : $@convention(thin) (Int64, @inout_aliasable Int64) -> ()
201+
// CHECK: [[SPECIALIZED_FN1:%.*]] = function_ref @{{.*}}address_closure_user{{.*}} : $@convention(thin) (Int32, @inout_aliasable Int32) -> ()
202202
// CHECK: apply [[SPECIALIZED_FN1]]{{.*}}
203203
// CHECK-NOT: partial_apply
204204
// CHECK: return
205-
sil @address_caller_trivial: $@convention(thin) (Int64) -> Int64 {
206-
bb0(%0 : $Int64):
207-
%2 = alloc_stack $Int64, var, name "xx"
208-
store %0 to %2 : $*Int64
205+
sil @address_caller_trivial: $@convention(thin) (Int32) -> Int32 {
206+
bb0(%0 : $Int32):
207+
%2 = alloc_stack $Int32, var, name "xx"
208+
store %0 to %2 : $*Int32
209209
// function_ref address_closure_user(f:)
210210
%4 = function_ref @address_closure_user : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
211211
// function_ref address_closure_trivial(x:)
212-
%5 = function_ref @address_closure_trivial : $@convention(thin) (Int64, @inout_aliasable Int64) -> ()
213-
%6 = partial_apply %5(%0, %2) : $@convention(thin) (Int64, @inout_aliasable Int64) -> ()
212+
%5 = function_ref @address_closure_trivial : $@convention(thin) (Int32, @inout_aliasable Int32) -> ()
213+
%6 = partial_apply %5(%0, %2) : $@convention(thin) (Int32, @inout_aliasable Int32) -> ()
214214
%7 = apply %4(%6) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
215-
%8 = load %2 : $*Int64
216-
dealloc_stack %2 : $*Int64
217-
return %8 : $Int64
215+
%8 = load %2 : $*Int32
216+
dealloc_stack %2 : $*Int32
217+
return %8 : $Int32
218218
}
219219

220-
sil @address_closure_trivial_mutating : $@convention(thin) (@inout_aliasable Int64) -> () {
221-
bb0(%0 : $*Int64):
222-
%2 = struct_element_addr %0 : $*Int64, #Int64._value
223-
%3 = load %2 : $*Builtin.Int64
224-
%4 = integer_literal $Builtin.Int64, 1
220+
sil @address_closure_trivial_mutating : $@convention(thin) (@inout_aliasable Int32) -> () {
221+
bb0(%0 : $*Int32):
222+
%2 = struct_element_addr %0 : $*Int32, #Int32._value
223+
%3 = load %2 : $*Builtin.Int32
224+
%4 = integer_literal $Builtin.Int32, 1
225225
%5 = integer_literal $Builtin.Int1, -1
226-
%6 = builtin "sadd_with_overflow_Int64"(%3 : $Builtin.Int64, %4 : $Builtin.Int64, %5 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
227-
%7 = tuple_extract %6 : $(Builtin.Int64, Builtin.Int1), 0
228-
%8 = tuple_extract %6 : $(Builtin.Int64, Builtin.Int1), 1
226+
%6 = builtin "sadd_with_overflow_Int32"(%3 : $Builtin.Int32, %4 : $Builtin.Int32, %5 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
227+
%7 = tuple_extract %6 : $(Builtin.Int32, Builtin.Int1), 0
228+
%8 = tuple_extract %6 : $(Builtin.Int32, Builtin.Int1), 1
229229
cond_fail %8 : $Builtin.Int1
230-
%10 = struct $Int64 (%7 : $Builtin.Int64)
231-
store %10 to %0 : $*Int64
230+
%10 = struct $Int32 (%7 : $Builtin.Int32)
231+
store %10 to %0 : $*Int32
232232
%12 = tuple ()
233233
return %12 : $()
234234
}
235235

236236
// CHECK-LABEL: sil @address_caller_trivial_mutating
237237
// CHECK-NOT: partial_apply
238-
// CHECK: [[SPECIALIZED_FN1:%.*]] = function_ref @{{.*}}address_closure_user{{.*}} : $@convention(thin) (@inout_aliasable Int64) -> ()
238+
// CHECK: [[SPECIALIZED_FN1:%.*]] = function_ref @{{.*}}address_closure_user{{.*}} : $@convention(thin) (@inout_aliasable Int32) -> ()
239239
// CHECK: apply [[SPECIALIZED_FN1]]{{.*}}
240240
// CHECK-NOT: partial_apply
241241
// CHECK: return
242-
sil @address_caller_trivial_mutating: $@convention(thin) (Int64) -> Int64 {
243-
bb0(%0 : $Int64):
244-
%2 = alloc_stack $Int64, var, name "xx"
245-
store %0 to %2 : $*Int64
242+
sil @address_caller_trivial_mutating: $@convention(thin) (Int32) -> Int32 {
243+
bb0(%0 : $Int32):
244+
%2 = alloc_stack $Int32, var, name "xx"
245+
store %0 to %2 : $*Int32
246246
%4 = function_ref @address_closure_user : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
247-
%5 = function_ref @address_closure_trivial_mutating : $@convention(thin) (@inout_aliasable Int64) -> () // user: %6
248-
%6 = partial_apply %5(%2) : $@convention(thin) (@inout_aliasable Int64) -> () // user: %7
247+
%5 = function_ref @address_closure_trivial_mutating : $@convention(thin) (@inout_aliasable Int32) -> () // user: %6
248+
%6 = partial_apply %5(%2) : $@convention(thin) (@inout_aliasable Int32) -> () // user: %7
249249
%7 = apply %4(%6) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
250-
%8 = load %2 : $*Int64
251-
dealloc_stack %2 : $*Int64
252-
return %8 : $Int64
250+
%8 = load %2 : $*Int32
251+
dealloc_stack %2 : $*Int32
252+
return %8 : $Int32
253253
}
254254

255255
// CHECK-LABEL: sil @address_caller_existential
@@ -260,8 +260,8 @@ bb0(%0 : $Int64):
260260
// CHECK: apply [[SPECIALIZED_FN1]]{{.*}}
261261
// CHECK-NOT: partial_apply
262262
// CHECK: return
263-
sil @address_caller_existential : $@convention(thin) (@in P, @in P, Int) -> @out P {
264-
bb0(%0 : $*P, %1 : $*P, %2 : $*P, %3 : $Int):
263+
sil @address_caller_existential : $@convention(thin) (@in P, @in P, Int32) -> @out P {
264+
bb0(%0 : $*P, %1 : $*P, %2 : $*P, %3 : $Int32):
265265
%7 = alloc_stack $P
266266
copy_addr %1 to [initialization] %7 : $*P
267267
%9 = function_ref @address_closure_existential : $@convention(thin) (@inout_aliasable P) -> ()
@@ -271,9 +271,9 @@ bb0(%0 : $*P, %1 : $*P, %2 : $*P, %3 : $Int):
271271
%14 = apply %12(%10) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
272272
strong_retain %10 : $@callee_owned () -> ()
273273
%16 = apply %12(%10) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
274-
%17 = integer_literal $Builtin.Int64, 10
275-
%18 = struct_extract %3 : $Int, #Int._value
276-
%19 = builtin "cmp_slt_Int64"(%17 : $Builtin.Int64, %18 : $Builtin.Int64) : $Builtin.Int1
274+
%17 = integer_literal $Builtin.Int32, 10
275+
%18 = struct_extract %3 : $Int32, #Int32._value
276+
%19 = builtin "cmp_slt_Int32"(%17 : $Builtin.Int32, %18 : $Builtin.Int32) : $Builtin.Int1
277277
cond_br %19, bb1, bb2
278278

279279
bb1:

0 commit comments

Comments
 (0)