@@ -48,6 +48,10 @@ struct MyInt {
4848 var value: Builtin.Int32
4949}
5050
51+ struct NativeObjectStruct {
52+ var ele : Builtin.NativeObject
53+ }
54+
5155sil [global_init] @global_init_fun : $@convention(thin) () -> Builtin.RawPointer
5256
5357sil [ossa] @user : $@convention(thin) (@owned Builtin.NativeObject) -> ()
@@ -1373,18 +1377,33 @@ bb0(%0 : @owned $B):
13731377}
13741378
13751379// (upcast X2->X (ref-to-object-pointer-inst (object-pointer-to-ref-inst x) typeof(x))) -> x
1376- // CHECK-LABEL: sil [ossa] @upcast_unchecked_ref_cast_round_trip : $@convention(thin) (@owned E) -> @owned E {
1380+ // CHECK-LABEL: sil [ossa] @upcast_unchecked_ref_cast_round_trip1 : $@convention(thin) (@owned E) -> @owned E {
13771381// CHECK-NOT: upcast
13781382// CHECK-NOT: unchecked_ref_cast
1379- // CHECK: } // end sil function 'upcast_unchecked_ref_cast_round_trip '
1380- sil [ossa] @upcast_unchecked_ref_cast_round_trip : $@convention(thin) (@owned E) -> @owned E {
1383+ // CHECK: } // end sil function 'upcast_unchecked_ref_cast_round_trip1 '
1384+ sil [ossa] @upcast_unchecked_ref_cast_round_trip1 : $@convention(thin) (@owned E) -> @owned E {
13811385bb0(%0 : @owned $E):
13821386 %1 = upcast %0 : $E to $B
13831387 %2 = unchecked_ref_cast %1 : $B to $Builtin.NativeObject
13841388 %3 = unchecked_ref_cast %2 : $Builtin.NativeObject to $E
13851389 return %3 : $E
13861390}
13871391
1392+ // CHECK-LABEL: sil [ossa] @upcast_unchecked_ref_cast_round_trip2 :
1393+ // CHECK-NOT: upcast
1394+ // CHECK-NOT: unchecked_ref_cast
1395+ // CHECK-LABEL: } // end sil function 'upcast_unchecked_ref_cast_round_trip2'
1396+ sil [ossa] @upcast_unchecked_ref_cast_round_trip2 : $@convention(method) (@owned E) -> () {
1397+ bb0(%0 : @owned $E):
1398+ %1 = upcast %0 : $E to $B
1399+ debug_value %1 : $B
1400+ %2 = unchecked_ref_cast %1 : $B to $Builtin.NativeObject
1401+ %3 = struct $NativeObjectStruct (%2 : $Builtin.NativeObject)
1402+ destroy_value %3 : $NativeObjectStruct
1403+ %res = tuple ()
1404+ return %res : $()
1405+ }
1406+
13881407// (load (upcast-addr %x)) -> (upcast-ref (load %x))
13891408//
13901409// CHECK-LABEL: sil [ossa] @load_upcast_addr_to_upcast_ref_load_canonicalization : $@convention(thin) (@inout E) -> @owned B {
0 commit comments