@@ -302,6 +302,57 @@ bbExitBlock(%result : @owned $FakeOptional<Klass>):
302
302
return %result : $FakeOptional<Klass>
303
303
}
304
304
305
+ // CHECK-LABEL: sil [ossa] @owned_to_guaranteed_rauw_2 : $@convention(thin) (@guaranteed Klass) -> @owned (Klass, Klass) {
306
+ // CHECK: bb0(
307
+ // CHECK-NEXT: tuple
308
+ // CHECK-NEXT: copy_value
309
+ // CHECK-NEXT: return
310
+ // CHECK: } // end sil function 'owned_to_guaranteed_rauw_2'
311
+ sil [ossa] @owned_to_guaranteed_rauw_2 : $@convention(thin) (@guaranteed Klass) -> @owned (Klass, Klass) {
312
+ bb0(%0 : @guaranteed $Klass):
313
+ %1 = unchecked_bitwise_cast %0 : $Klass to $SubKlass
314
+ %2 = unchecked_bitwise_cast %1 : $SubKlass to $Klass
315
+ %3 = tuple(%2 : $Klass, %2 : $Klass)
316
+ %4 = copy_value %3
317
+ return %4 : $(Klass, Klass)
318
+ }
319
+
320
+ // CHECK-LABEL: sil [ossa] @owned_to_guaranteed_rauw_2a : $@convention(thin) (@guaranteed Builtin.NativeObject) -> @owned (Klass, Klass) {
321
+ // CHECK: bb0(
322
+ // CHECK-NEXT: unchecked_ref_cast
323
+ // CHECK-NEXT: tuple
324
+ // CHECK-NEXT: copy_value
325
+ // CHECK-NEXT: return
326
+ // CHECK: } // end sil function 'owned_to_guaranteed_rauw_2a'
327
+ sil [ossa] @owned_to_guaranteed_rauw_2a : $@convention(thin) (@guaranteed Builtin.NativeObject) -> @owned (Klass, Klass) {
328
+ bb0(%0 : @guaranteed $Builtin.NativeObject):
329
+ %0a = unchecked_ref_cast %0 : $Builtin.NativeObject to $Klass
330
+ %1 = unchecked_bitwise_cast %0a : $Klass to $SubKlass
331
+ %2 = unchecked_bitwise_cast %1 : $SubKlass to $Klass
332
+ %3 = tuple(%2 : $Klass, %2 : $Klass)
333
+ %4 = copy_value %3
334
+ return %4 : $(Klass, Klass)
335
+ }
336
+
337
+ // We need the unchecked_ownership_conversion since our base value is
338
+ // guaranteed, not a function argument, and our user is a function exiting
339
+ // terminator.
340
+ //
341
+ // CHECK-LABEL: sil [ossa] @owned_to_guaranteed_rauw_2b : $@convention(thin) (@guaranteed Builtin.NativeObject) -> @owned Klass {
342
+ // CHECK: bb0(
343
+ // CHECK-NEXT: unchecked_ref_cast
344
+ // CHECK-NEXT: copy_value
345
+ // CHECK-NEXT: return
346
+ // CHECK: } // end sil function 'owned_to_guaranteed_rauw_2b'
347
+ sil [ossa] @owned_to_guaranteed_rauw_2b : $@convention(thin) (@guaranteed Builtin.NativeObject) -> @owned Klass {
348
+ bb0(%0 : @guaranteed $Builtin.NativeObject):
349
+ %0a = unchecked_ref_cast %0 : $Builtin.NativeObject to $Klass
350
+ %1 = unchecked_bitwise_cast %0a : $Klass to $SubKlass
351
+ %2 = unchecked_bitwise_cast %1 : $SubKlass to $Klass
352
+ %3 = copy_value %2
353
+ return %3 : $Klass
354
+ }
355
+
305
356
// CHECK-LABEL: sil [ossa] @unowned_to_guaranteed_rauw_2_loop : $@convention(thin) (@guaranteed Klass) -> @owned FakeOptional<(Klass, Klass)> {
306
357
// CHECK: bb0([[ARG:%.*]] : @guaranteed $Klass):
307
358
// CHECK-NOT: unchecked_bitwise_cast
@@ -358,6 +409,19 @@ bbExitBlock(%result : @owned $FakeOptional<(Klass, Klass)>):
358
409
return %result : $FakeOptional<(Klass, Klass)>
359
410
}
360
411
412
+ // CHECK-LABEL: sil [ossa] @owned_to_guaranteed_rauw_3 : $@convention(thin) (@guaranteed Klass) -> @owned Klass {
413
+ // CHECK: bb0(
414
+ // CHECK-NEXT: copy_value
415
+ // CHECK-NEXT: return
416
+ // CHECK: } // end sil function 'owned_to_guaranteed_rauw_3'
417
+ sil [ossa] @owned_to_guaranteed_rauw_3 : $@convention(thin) (@guaranteed Klass) -> @owned Klass {
418
+ bb0(%0 : @guaranteed $Klass):
419
+ %1 = unchecked_bitwise_cast %0 : $Klass to $SubKlass
420
+ %2 = unchecked_bitwise_cast %1 : $SubKlass to $Klass
421
+ %3 = copy_value %2
422
+ return %3 : $Klass
423
+ }
424
+
361
425
//===---
362
426
// Guaranteed Tests
363
427
//
0 commit comments