Skip to content

Commit f8d9042

Browse files
committed
Fix check lines in array property opt test
1 parent 5522d3d commit f8d9042

File tree

1 file changed

+41
-23
lines changed

1 file changed

+41
-23
lines changed

test/SILOptimizer/array_property_opt.sil

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ enum MyBool{
2525
class MyClass {
2626
}
2727

28+
struct MyInt {
29+
@_hasStorage var _value: Builtin.Int64
30+
}
31+
2832
// CHECK-LABEL: sil @clone_switch_enum_exit :
2933
// CHECK: bb1:
3034
// CHECK: [[FUNC1:%.*]] = function_ref @arrayPropertyIsNative
@@ -264,7 +268,7 @@ bb11: // Non-exit dominated by bb1
264268
}
265269

266270
class Klass {
267-
var val: Optional<Int>
271+
var val: Optional<MyInt>
268272
}
269273

270274
struct WrapperStruct {
@@ -273,6 +277,13 @@ struct WrapperStruct {
273277

274278
sil @use_klass : $@convention(thin) (@in_guaranteed Klass) -> ()
275279

280+
// Test verifier does not fire for address phis
281+
// Check if array property opt is kicking in by looking for 2 calls to hoistableIsNativeTypeChecked
282+
// CHECK-LABEL: sil @test_sink_address_proj :
283+
// [[FUNC:%.*]] = function_ref @arrayPropertyIsNative : $@convention(method) (@owned MyArray<MyClass>) -> Bool
284+
// apply [[FUNC]]
285+
// apply [[FUNC]]
286+
// CHECK-LABEL: } // end sil function 'test_sink_address_proj'
276287
sil @test_sink_address_proj : $@convention(thin) (@inout MyArray<MyClass>, @in_guaranteed WrapperStruct) -> () {
277288
bb0(%0 : $*MyArray<MyClass>, %1 : $*WrapperStruct):
278289
%3 = load %0 : $*MyArray<MyClass>
@@ -306,10 +317,17 @@ bb6:
306317
}
307318

308319
sil [_semantics "array.props.isNativeTypeChecked"] @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed Array<Klass>) -> Bool
309-
sil [_semantics "array.get_element"] @getElement : $@convention(method) (Int, Bool, _DependenceToken, @guaranteed Array<Klass>) -> @owned Klass
310-
sil [_semantics "array.get_count"] @getCount : $@convention(method) (@guaranteed Array<Klass>) -> Int
311-
312-
sil hidden @test_array_prop_opt : $@convention(thin) (@guaranteed Optional<Array<Klass>>) -> Int {
320+
sil [_semantics "array.get_element"] @getElement : $@convention(method) (MyInt, Bool, _DependenceToken, @guaranteed Array<Klass>) -> @owned Klass
321+
sil [_semantics "array.get_count"] @getCount : $@convention(method) (@guaranteed Array<Klass>) -> MyInt
322+
323+
// Test verifier does not fire for address phis
324+
// Check if array property opt is kicking in by looking for 2 calls to hoistableIsNativeTypeChecked
325+
// CHECK-LABEL: sil @test_array_prop_opt :
326+
// [[FUNC:%.*]] = function_ref @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed Array<Klass>) -> Bool
327+
// apply [[FUNC]]
328+
// apply [[FUNC]]
329+
// CHECK-LABEL: } // end sil function 'test_array_prop_opt'
330+
sil @test_array_prop_opt : $@convention(thin) (@guaranteed Optional<Array<Klass>>) -> MyInt {
313331
bb0(%0 : $Optional<Array<Klass>>):
314332
%4 = integer_literal $Builtin.Int64, 0
315333
switch_enum %0 : $Optional<Array<Klass>>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb1
@@ -318,11 +336,11 @@ bb1:
318336
br bb12(%4 : $Builtin.Int64)
319337

320338
bb2(%12 : $Array<Klass>):
321-
%14 = function_ref @getCount : $@convention(method) (@guaranteed Array<Klass>) -> Int
339+
%14 = function_ref @getCount : $@convention(method) (@guaranteed Array<Klass>) -> MyInt
322340
retain_value %0 : $Optional<Array<Klass>>
323341
retain_value %0 : $Optional<Array<Klass>>
324-
%17 = apply %14(%12) : $@convention(method) (@guaranteed Array<Klass>) -> Int
325-
%18 = struct_extract %17 : $Int, #Int._value
342+
%17 = apply %14(%12) : $@convention(method) (@guaranteed Array<Klass>) -> MyInt
343+
%18 = struct_extract %17 : $MyInt, #MyInt._value
326344
%19 = builtin "cmp_eq_Int64"(%18 : $Builtin.Int64, %4 : $Builtin.Int64) : $Builtin.Int1
327345
cond_br %19, bb3, bb4
328346

@@ -337,25 +355,25 @@ bb3:
337355

338356
bb4:
339357
%28 = function_ref @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed Array<Klass>) -> Bool
340-
%29 = function_ref @getElement : $@convention(method) (Int, Bool, _DependenceToken, @guaranteed Array<Klass>) -> @owned Klass
358+
%29 = function_ref @getElement : $@convention(method) (MyInt, Bool, _DependenceToken, @guaranteed Array<Klass>) -> @owned Klass
341359
%30 = integer_literal $Builtin.Int64, 1
342360
%31 = integer_literal $Builtin.Int1, -1
343361
%32 = struct $_DependenceToken ()
344362
br bb5(%4 : $Builtin.Int64)
345363

346364
bb5(%34 : $Builtin.Int64):
347-
%35 = struct $Int (%34 : $Builtin.Int64)
365+
%35 = struct $MyInt (%34 : $Builtin.Int64)
348366
%36 = apply %28(%12) : $@convention(method) (@guaranteed Array<Klass>) -> Bool
349-
%37 = apply %29(%35, %36, %32, %12) : $@convention(method) (Int, Bool, _DependenceToken, @guaranteed Array<Klass>) -> @owned Klass
367+
%37 = apply %29(%35, %36, %32, %12) : $@convention(method) (MyInt, Bool, _DependenceToken, @guaranteed Array<Klass>) -> @owned Klass
350368
%38 = builtin "sadd_with_overflow_Int64"(%34 : $Builtin.Int64, %30 : $Builtin.Int64, %31 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
351369
%39 = tuple_extract %38 : $(Builtin.Int64, Builtin.Int1), 0
352370
%40 = tuple_extract %38 : $(Builtin.Int64, Builtin.Int1), 1
353371
cond_fail %40 : $Builtin.Int1, "arithmetic overflow"
354372
%43 = ref_element_addr %37 : $Klass, #Klass.val
355-
%44 = begin_access [read] [dynamic] [no_nested_conflict] %43 : $*Optional<Int>
356-
%45 = load %44 : $*Optional<Int>
357-
end_access %44 : $*Optional<Int>
358-
switch_enum %45 : $Optional<Int>, case #Optional.some!enumelt: bb9, case #Optional.none!enumelt: bb6
373+
%44 = begin_access [read] [dynamic] [no_nested_conflict] %43 : $*Optional<MyInt>
374+
%45 = load %44 : $*Optional<MyInt>
375+
end_access %44 : $*Optional<MyInt>
376+
switch_enum %45 : $Optional<MyInt>, case #Optional.some!enumelt: bb9, case #Optional.none!enumelt: bb6
359377

360378
bb6:
361379
strong_release %37 : $Klass
@@ -372,22 +390,22 @@ bb8:
372390

373391
bb9:
374392
release_value %0 : $Optional<Array<Klass>>
375-
%57 = begin_access [read] [dynamic] [no_nested_conflict] %43 : $*Optional<Int>
376-
%58 = load %57 : $*Optional<Int>
377-
end_access %57 : $*Optional<Int>
378-
switch_enum %58 : $Optional<Int>, case #Optional.some!enumelt: bb11, case #Optional.none!enumelt: bb10
393+
%57 = begin_access [read] [dynamic] [no_nested_conflict] %43 : $*Optional<MyInt>
394+
%58 = load %57 : $*Optional<MyInt>
395+
end_access %57 : $*Optional<MyInt>
396+
switch_enum %58 : $Optional<MyInt>, case #Optional.some!enumelt: bb11, case #Optional.none!enumelt: bb10
379397

380398
bb10:
381399
cond_fail %31 : $Builtin.Int1, "Unexpectedly found nil while unwrapping an Optional value"
382400
unreachable
383401

384-
bb11(%63 : $Int):
402+
bb11(%63 : $MyInt):
385403
release_value %0 : $Optional<Array<Klass>>
386404
strong_release %37 : $Klass
387-
%66 = struct_extract %63 : $Int, #Int._value
405+
%66 = struct_extract %63 : $MyInt, #MyInt._value
388406
br bb12(%66 : $Builtin.Int64)
389407

390408
bb12(%69 : $Builtin.Int64):
391-
%70 = struct $Int (%69 : $Builtin.Int64)
392-
return %70 : $Int
409+
%70 = struct $MyInt (%69 : $Builtin.Int64)
410+
return %70 : $MyInt
393411
}

0 commit comments

Comments
 (0)