Skip to content

Commit edb2aa8

Browse files
authored
codegen: More robustness for invalid :invoke IR (#58631)
See #58429 for general discussion of these kinds of errors. We don't verify this one in the IR verifier, because it's currently not really part of the structural invariants of the IR. One could imagine using IRCode with a non-codegen backend that uses something else here. Nevertheless, codegen needs to complain of course if someone put something here it doesn't understand.
1 parent 7498f34 commit edb2aa8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/codegen.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5184,10 +5184,12 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, const jl_cgval_t &lival, ArrayR
51845184
if (jl_is_method_instance(lival.constant)) {
51855185
mi = (jl_method_instance_t*)lival.constant;
51865186
}
5187-
else {
5187+
else if (jl_is_code_instance(lival.constant)) {
51885188
ci = lival.constant;
5189-
assert(jl_is_code_instance(ci));
51905189
mi = jl_get_ci_mi((jl_code_instance_t*)ci);
5190+
} else {
5191+
emit_error(ctx, "(Internal ERROR - IR Validity): Invoke target is not a method instance or code instance");
5192+
return jl_cgval_t();
51915193
}
51925194
assert(jl_is_method_instance(mi));
51935195
if (mi == ctx.linfo) {

0 commit comments

Comments
 (0)