|
852 | 852 | struct Value {}
|
853 | 853 |
|
854 | 854 | class AnObject {}
|
| 855 | +class AnSubObject : AnObject {} |
855 | 856 |
|
856 | 857 | // CHECK-LABEL: sil [ossa] @replace_unconditional_check_cast_failure
|
857 | 858 | // CHECK: bb2:
|
@@ -1084,3 +1085,50 @@ bb0(%0 : $*Error, %1 : $*E1):
|
1084 | 1085 | %2 = tuple ()
|
1085 | 1086 | return %2 : $()
|
1086 | 1087 | }
|
| 1088 | + |
| 1089 | +// CHECK-LABEL: sil [ossa] @always_fail_protocolmeta_to_concretemeta_checkedcastbr : $@convention(thin) (@thin P.Protocol) -> Builtin.Int1 { |
| 1090 | +// CHECK: bb0( |
| 1091 | +// CHECK-NEXT: metatype |
| 1092 | +// CHECK-NEXT: br bb2( |
| 1093 | +// CHECK: } // end sil function 'always_fail_protocolmeta_to_concretemeta_checkedcastbr' |
| 1094 | +sil [ossa] @always_fail_protocolmeta_to_concretemeta_checkedcastbr : $@convention(thin) (@thin P.Protocol) -> Builtin.Int1 { |
| 1095 | +bb0(%0 : $@thin P.Protocol): |
| 1096 | + %2 = metatype $@thick P.Protocol |
| 1097 | + checked_cast_br %2 : $@thick P.Protocol to $@thick X.Type, bb1, bb2 |
| 1098 | + |
| 1099 | +bb1(%4 : $@thick X.Type): |
| 1100 | + %5 = metatype $@thin X.Type |
| 1101 | + %6 = integer_literal $Builtin.Int1, -1 |
| 1102 | + br bb3(%6 : $Builtin.Int1) |
| 1103 | + |
| 1104 | +bb2(%8 : $@thick P.Protocol): |
| 1105 | + %9 = integer_literal $Builtin.Int1, 0 |
| 1106 | + br bb3(%9 : $Builtin.Int1) |
| 1107 | + |
| 1108 | +bb3(%11 : $Builtin.Int1): |
| 1109 | + return %11 : $Builtin.Int1 |
| 1110 | +} |
| 1111 | + |
| 1112 | +// CHECK-LABEL: sil [ossa] @always_succeed_subtoparent : $@convention(thin) (@owned AnSubObject) -> Builtin.Int1 { |
| 1113 | +// CHECK: bb0( |
| 1114 | +// CHECK-NEXT: upcast |
| 1115 | +// CHECK-NEXT: br bb1( |
| 1116 | +// CHECK: } // end sil function 'always_succeed_subtoparent' |
| 1117 | +sil [ossa] @always_succeed_subtoparent : $@convention(thin) (@owned AnSubObject) -> Builtin.Int1 { |
| 1118 | +bb0(%0 : @owned $AnSubObject): |
| 1119 | + checked_cast_br %0 : $AnSubObject to $AnObject, bb1, bb2 |
| 1120 | + |
| 1121 | +bb1(%4 : @owned $AnObject): |
| 1122 | + %5 = metatype $@thin X.Type |
| 1123 | + %6 = integer_literal $Builtin.Int1, -1 |
| 1124 | + destroy_value %4 : $AnObject |
| 1125 | + br bb3(%6 : $Builtin.Int1) |
| 1126 | + |
| 1127 | +bb2(%8 : @owned $AnSubObject): |
| 1128 | + %9 = integer_literal $Builtin.Int1, 0 |
| 1129 | + destroy_value %8 : $AnSubObject |
| 1130 | + br bb3(%9 : $Builtin.Int1) |
| 1131 | + |
| 1132 | +bb3(%11 : $Builtin.Int1): |
| 1133 | + return %11 : $Builtin.Int1 |
| 1134 | +} |
0 commit comments