Skip to content

Commit cc82c07

Browse files
committed
make emit_isa change more minimal
1 parent 1ea6a51 commit cc82c07

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

src/cgutils.cpp

+9-20
Original file line numberDiff line numberDiff line change
@@ -1060,33 +1060,22 @@ static void emit_type_error(jl_codectx_t &ctx, const jl_cgval_t &x, Value *type,
10601060

10611061
static std::pair<Value*, bool> emit_isa(jl_codectx_t &ctx, const jl_cgval_t &x, jl_value_t *type, const std::string *msg)
10621062
{
1063-
jl_value_t *intersected_type = type;
1064-
1063+
// TODO: The subtype check below suffers from incorrectness issues due to broken
1064+
// subtyping for kind types (see https://github.com/JuliaLang/julia/issues/27078). For
1065+
// actual `isa` calls, this optimization should already have been performed upstream
1066+
// anyway, but having this optimization in codegen might still be beneficial for
1067+
// `typeassert`s if we can make it correct.
10651068
Optional<bool> known_isa;
1066-
if (x.constant) {
1069+
jl_value_t *intersected_type = type;
1070+
if (x.constant)
10671071
known_isa = jl_isa(x.constant, type);
1072+
else if (jl_subtype(x.typ, type)) {
1073+
// known_isa = true;
10681074
} else {
10691075
intersected_type = jl_type_intersection(x.typ, type);
10701076
if (intersected_type == (jl_value_t*)jl_bottom_type)
10711077
known_isa = false;
10721078
}
1073-
1074-
// TODO: This commented-out version of the above check suffers from incorrectness
1075-
// issues due to broken subtyping for kind types (see
1076-
// https://github.com/JuliaLang/julia/issues/27078). For actual `isa` calls, this
1077-
// optimization should already have been performed upstream anyway, but having this
1078-
// optimization in codegen might still be beneficial for `typeassert`s if we can make it
1079-
// correct.
1080-
// if (x.constant) {
1081-
// known_isa = jl_isa(x.constant, type);
1082-
// else if (jl_subtype(x.typ, type))
1083-
// known_isa = true;
1084-
// else {
1085-
// intersected_type = jl_type_intersection(x.typ, type);
1086-
// if (intersected_type == (jl_value_t*)jl_bottom_type)
1087-
// known_isa = false;
1088-
// }
1089-
10901079
if (known_isa) {
10911080
if (!*known_isa && msg) {
10921081
emit_type_error(ctx, x, literal_pointer_val(ctx, type), *msg);

0 commit comments

Comments
 (0)