Skip to content

Commit

Permalink
Turn some asserts into runtime traps instead
Browse files Browse the repository at this point in the history
Unfortunately, we cannnot always rely on :invokes to have argument
values that match the declared ssa types (e.g. if the :invoke is
dynamically unreachable). Because of that, we cannot assert here,
but must instead emit a runtime trap.
  • Loading branch information
Keno authored and jrevels committed Oct 5, 2018
1 parent 45017f6 commit 29d8f08
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2979,6 +2979,12 @@ static jl_cgval_t emit_call_specfun_other(jl_codectx_t &ctx, jl_method_instance_
argvals[idx] = maybe_decay_untracked(boxed(ctx, arg));
}
else if (et->isAggregateType()) {
if (!arg.ispointer()) {
// This can happen in dead code if there's a type mismatch
// Exit early
CreateTrap(ctx.builder);
return jl_cgval_t();
}
// can lazy load on demand, no copy needed
assert(at == PointerType::get(et, AddressSpace::Derived));
assert(arg.ispointer());
Expand All @@ -2987,7 +2993,13 @@ static jl_cgval_t emit_call_specfun_other(jl_codectx_t &ctx, jl_method_instance_
}
else {
assert(at == et);
argvals[idx] = emit_unbox(ctx, et, arg, jt);
Value *val = emit_unbox(ctx, et, arg, jt);
if (!val) {
// There was a type mismatch of some sort - exit early
CreateTrap(ctx.builder);
return jl_cgval_t();
}
argvals[idx] = val;
}
idx++;
}
Expand Down

0 comments on commit 29d8f08

Please sign in to comment.