@@ -258,3 +258,132 @@ bb10: // Exit dominated by bb3
258
258
bb11: // Non-exit dominated by bb1
259
259
return %4 : $Builtin.Int1
260
260
}
261
+
262
+ class Klass {
263
+ var val: Optional<Int>
264
+ }
265
+
266
+ struct WrapperStruct {
267
+ var val: Klass
268
+ }
269
+
270
+ sil @use_klass : $@convention(thin) (@in_guaranteed Klass) -> ()
271
+
272
+ sil @test_sink_address_proj : $@convention(thin) (@inout MyArray<MyClass>, @in_guaranteed WrapperStruct) -> () {
273
+ bb0(%0 : $*MyArray<MyClass>, %1 : $*WrapperStruct):
274
+ %3 = load %0 : $*MyArray<MyClass>
275
+ br bb1
276
+
277
+ bb1:
278
+ %2 = function_ref @arrayPropertyIsNative : $@convention(method) (@owned MyArray<MyClass>) -> Bool
279
+ retain_value %3 : $MyArray<MyClass>
280
+ %5 = apply %2(%3) : $@convention(method) (@owned MyArray<MyClass>) -> Bool
281
+ %ele = struct_element_addr %1 : $*WrapperStruct, #WrapperStruct.val
282
+ cond_br undef, bb5, bb2
283
+
284
+ bb2:
285
+ %6 = integer_literal $Builtin.Int1, -1
286
+ cond_br %6, bb3, bb4
287
+
288
+ bb3:
289
+ br bb1
290
+
291
+ bb4:
292
+ br bb6
293
+
294
+ bb5:
295
+ %f = function_ref @use_klass : $@convention(thin) (@in_guaranteed Klass) -> ()
296
+ %a = apply %f(%ele) : $@convention(thin) (@in_guaranteed Klass) -> ()
297
+ br bb6
298
+
299
+ bb6:
300
+ %t = tuple ()
301
+ return %t : $()
302
+ }
303
+
304
+ sil [_semantics "array.props.isNativeTypeChecked"] @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed Array<Klass>) -> Bool
305
+ sil [_semantics "array.get_element"] @getElement : $@convention(method) (Int, Bool, _DependenceToken, @guaranteed Array<Klass>) -> @owned Klass
306
+ sil [_semantics "array.get_count"] @getCount : $@convention(method) (@guaranteed Array<Klass>) -> Int
307
+
308
+ sil hidden @test_array_prop_opt : $@convention(thin) (@guaranteed Optional<Array<Klass>>) -> Int {
309
+ bb0(%0 : $Optional<Array<Klass>>):
310
+ %4 = integer_literal $Builtin.Int64, 0
311
+ switch_enum %0 : $Optional<Array<Klass>>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb1
312
+
313
+ bb1:
314
+ br bb12(%4 : $Builtin.Int64)
315
+
316
+ bb2(%12 : $Array<Klass>):
317
+ %14 = function_ref @getCount : $@convention(method) (@guaranteed Array<Klass>) -> Int
318
+ retain_value %0 : $Optional<Array<Klass>>
319
+ retain_value %0 : $Optional<Array<Klass>>
320
+ %17 = apply %14(%12) : $@convention(method) (@guaranteed Array<Klass>) -> Int
321
+ %18 = struct_extract %17 : $Int, #Int._value
322
+ %19 = builtin "cmp_eq_Int64"(%18 : $Builtin.Int64, %4 : $Builtin.Int64) : $Builtin.Int1
323
+ cond_br %19, bb3, bb4
324
+
325
+ bb3:
326
+ release_value %0 : $Optional<Array<Klass>>
327
+ %22 = unchecked_enum_data %0 : $Optional<Array<Klass>>, #Optional.some!enumelt
328
+ %23 = struct_extract %22 : $Array<Klass>, #Array._buffer
329
+ %24 = struct_extract %23 : $_ArrayBuffer<Klass>, #_ArrayBuffer._storage
330
+ %25 = struct_extract %24 : $_BridgeStorage<__ContiguousArrayStorageBase>, #_BridgeStorage.rawValue
331
+ strong_release %25 : $Builtin.BridgeObject
332
+ br bb12(%4 : $Builtin.Int64)
333
+
334
+ bb4:
335
+ %28 = function_ref @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed Array<Klass>) -> Bool
336
+ %29 = function_ref @getElement : $@convention(method) (Int, Bool, _DependenceToken, @guaranteed Array<Klass>) -> @owned Klass
337
+ %30 = integer_literal $Builtin.Int64, 1
338
+ %31 = integer_literal $Builtin.Int1, -1
339
+ %32 = struct $_DependenceToken ()
340
+ br bb5(%4 : $Builtin.Int64)
341
+
342
+ bb5(%34 : $Builtin.Int64):
343
+ %35 = struct $Int (%34 : $Builtin.Int64)
344
+ %36 = apply %28(%12) : $@convention(method) (@guaranteed Array<Klass>) -> Bool
345
+ %37 = apply %29(%35, %36, %32, %12) : $@convention(method) (Int, Bool, _DependenceToken, @guaranteed Array<Klass>) -> @owned Klass
346
+ %38 = builtin "sadd_with_overflow_Int64"(%34 : $Builtin.Int64, %30 : $Builtin.Int64, %31 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
347
+ %39 = tuple_extract %38 : $(Builtin.Int64, Builtin.Int1), 0
348
+ %40 = tuple_extract %38 : $(Builtin.Int64, Builtin.Int1), 1
349
+ cond_fail %40 : $Builtin.Int1, "arithmetic overflow"
350
+ %43 = ref_element_addr %37 : $Klass, #Klass.val
351
+ %44 = begin_access [read] [dynamic] [no_nested_conflict] %43 : $*Optional<Int>
352
+ %45 = load %44 : $*Optional<Int>
353
+ end_access %44 : $*Optional<Int>
354
+ switch_enum %45 : $Optional<Int>, case #Optional.some!enumelt: bb9, case #Optional.none!enumelt: bb6
355
+
356
+ bb6:
357
+ strong_release %37 : $Klass
358
+ %49 = builtin "cmp_eq_Int64"(%39 : $Builtin.Int64, %18 : $Builtin.Int64) : $Builtin.Int1
359
+ cond_br %49, bb7, bb8
360
+
361
+ bb7:
362
+ release_value %0 : $Optional<Array<Klass>>
363
+ release_value %0 : $Optional<Array<Klass>>
364
+ br bb12(%4 : $Builtin.Int64)
365
+
366
+ bb8:
367
+ br bb5(%39 : $Builtin.Int64)
368
+
369
+ bb9:
370
+ release_value %0 : $Optional<Array<Klass>>
371
+ %57 = begin_access [read] [dynamic] [no_nested_conflict] %43 : $*Optional<Int>
372
+ %58 = load %57 : $*Optional<Int>
373
+ end_access %57 : $*Optional<Int>
374
+ switch_enum %58 : $Optional<Int>, case #Optional.some!enumelt: bb11, case #Optional.none!enumelt: bb10
375
+
376
+ bb10:
377
+ cond_fail %31 : $Builtin.Int1, "Unexpectedly found nil while unwrapping an Optional value"
378
+ unreachable
379
+
380
+ bb11(%63 : $Int):
381
+ release_value %0 : $Optional<Array<Klass>>
382
+ strong_release %37 : $Klass
383
+ %66 = struct_extract %63 : $Int, #Int._value
384
+ br bb12(%66 : $Builtin.Int64)
385
+
386
+ bb12(%69 : $Builtin.Int64):
387
+ %70 = struct $Int (%69 : $Builtin.Int64)
388
+ return %70 : $Int
389
+ }
0 commit comments