Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify try_eval and make it report non-constant SSAValues. #25797

Merged
merged 1 commit into from
Jan 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,25 +722,24 @@ static void interpret_symbol_arg(jl_codectx_t &ctx, native_sym_arg_t &out, jl_va
}


static jl_value_t* try_eval(jl_codectx_t &ctx, jl_value_t *ex, const char *failure, bool compiletime=false)
static jl_value_t* try_eval(jl_codectx_t &ctx, jl_value_t *ex, const char *failure)
{
jl_value_t *constant = NULL;
constant = static_eval(ctx, ex, true, true);
if (constant || jl_is_ssavalue(ex))
jl_value_t *constant = static_eval(ctx, ex, true, true);
if (jl_is_ssavalue(ex) && !constant)
jl_error(failure);
else if (constant)
return constant;

JL_TRY {
size_t last_age = jl_get_ptls_states()->world_age;
jl_get_ptls_states()->world_age = ctx.world;
constant = jl_interpret_toplevel_expr_in(ctx.module, ex, ctx.source, ctx.linfo->sparam_vals);
jl_get_ptls_states()->world_age = last_age;
}
JL_CATCH {
if (compiletime)
jl_rethrow_with_add(failure);
if (failure)
emit_error(ctx, failure);
constant = NULL;
jl_rethrow_with_add(failure);
}

return constant;
}

Expand Down Expand Up @@ -955,9 +954,9 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar
JL_NARGSV(llvmcall, 3);
jl_value_t *rt = NULL, *at = NULL, *ir = NULL, *decl = NULL;
JL_GC_PUSH4(&ir, &rt, &at, &decl);
at = try_eval(ctx, args[3], "error statically evaluating llvmcall argument tuple", true);
rt = try_eval(ctx, args[2], "error statically evaluating llvmcall return type", true);
ir = try_eval(ctx, args[1], "error statically evaluating llvm IR argument", true);
at = try_eval(ctx, args[3], "error statically evaluating llvmcall argument tuple");
rt = try_eval(ctx, args[2], "error statically evaluating llvmcall return type");
ir = try_eval(ctx, args[1], "error statically evaluating llvm IR argument");
int i = 1;
if (jl_is_tuple(ir)) {
// if the IR is a tuple, we expect (declarations, ir)
Expand Down