@@ -1062,31 +1062,32 @@ static std::pair<Value*, bool> emit_isa(jl_codectx_t &ctx, const jl_cgval_t &x,
1062
1062
{
1063
1063
jl_value_t *intersected_type = type;
1064
1064
1065
- // TODO: This optimization suffers from incorrectness issues due to broken subtyping for
1066
- // kind types (see https://github.com/JuliaLang/julia/issues/27078). For actual `isa`
1067
- // calls, this optimization should already have been performed upstream anyway, but
1068
- // having this optimization in codegen might still be beneficial for `typeassert`s
1069
- // if we can make it correct.
1070
- //
1071
- // Optional<bool> known_isa;
1072
- // if (x.constant)
1073
- // known_isa = jl_isa(x.constant, type);
1065
+ // TODO: The commented-out part of this optimization suffers from incorrectness issues
1066
+ // due to broken subtyping for kind types (see
1067
+ // https://github.com/JuliaLang/julia/issues/27078). For actual `isa` calls, this
1068
+ // optimization should already have been performed upstream anyway, but having this
1069
+ // optimization in codegen might still be beneficial for `typeassert`s if we can make it
1070
+ // correct.
1071
+ Optional<bool > known_isa;
1072
+ if (x.constant ) {
1073
+ known_isa = jl_isa (x.constant , type);
1074
+ }
1074
1075
// else if (jl_subtype(x.typ, type))
1075
1076
// known_isa = true;
1076
1077
// else {
1077
1078
// intersected_type = jl_type_intersection(x.typ, type);
1078
1079
// if (intersected_type == (jl_value_t*)jl_bottom_type)
1079
1080
// known_isa = false;
1080
1081
// }
1081
- // if (known_isa) {
1082
- // if (!*known_isa && msg) {
1083
- // emit_type_error(ctx, x, literal_pointer_val(ctx, type), *msg);
1084
- // ctx.builder.CreateUnreachable();
1085
- // BasicBlock *failBB = BasicBlock::Create(jl_LLVMContext, "fail", ctx.f);
1086
- // ctx.builder.SetInsertPoint(failBB);
1087
- // }
1088
- // return std::make_pair(ConstantInt::get(T_int1, *known_isa), true);
1089
- // }
1082
+ if (known_isa) {
1083
+ if (!*known_isa && msg) {
1084
+ emit_type_error (ctx, x, literal_pointer_val (ctx, type), *msg);
1085
+ ctx.builder .CreateUnreachable ();
1086
+ BasicBlock *failBB = BasicBlock::Create (jl_LLVMContext, " fail" , ctx.f );
1087
+ ctx.builder .SetInsertPoint (failBB);
1088
+ }
1089
+ return std::make_pair (ConstantInt::get (T_int1, *known_isa), true );
1090
+ }
1090
1091
1091
1092
// intersection with Type needs to be handled specially
1092
1093
if (jl_has_intersect_type_not_kind (type)) {
0 commit comments