From 17dea772579f5c7197ee33b3ad84bcf7249fd48b Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 1 Jun 2016 00:02:46 -0400 Subject: [PATCH] remove the ability for codegen to compute specialized call sites fix #16201 --- src/codegen.cpp | 59 +---------------------------------------------- test/inference.jl | 12 ++++++---- 2 files changed, 9 insertions(+), 62 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index f7db178aea654a..8cdf3a371e7764 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -2061,23 +2061,6 @@ static Value *emit_f_is(const jl_cgval_t &arg1, const jl_cgval_t &arg2, jl_codec #endif } -static jl_svec_t *call_arg_types(jl_value_t **args, size_t n, jl_codectx_t *ctx) -{ - jl_svec_t *t = jl_alloc_svec(n); - JL_GC_PUSH1(&t); - size_t i; - for(i=0; i < n; i++) { - jl_value_t *ty = expr_type(args[i], ctx); - if (!jl_is_leaf_type(ty)) { - t = NULL; - break; - } - jl_svecset(t, i, ty); - } - JL_GC_POP(); - return t; -} - static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args, size_t nargs, jl_codectx_t *ctx, jl_value_t *expr) // returns true if the call has been handled @@ -2731,11 +2714,10 @@ static jl_cgval_t emit_call(jl_expr_t *ex, jl_codectx_t *ctx) size_t nargs = arglen - 1; assert(arglen >= 1); Value *theFptr = NULL; - jl_value_t *aty = NULL; jl_cgval_t result; jl_function_t *f = (jl_function_t*)static_eval(args[0], ctx, true); - JL_GC_PUSH2(&f, &aty); + JL_GC_PUSH1(&f); if (f != NULL) { // function is a compile-time constant if (jl_typeis(f, jl_intrinsic_type)) { @@ -2765,45 +2747,6 @@ static jl_cgval_t emit_call(jl_expr_t *ex, jl_codectx_t *ctx) } } - if (ctx->linfo->inferred) { - aty = (jl_value_t*)call_arg_types(args, arglen, ctx); - // attempt compile-time specialization for inferred types - if (aty != NULL) { - aty = (jl_value_t*)jl_apply_tuple_type((jl_svec_t*)aty); - /*if (trace) { - jl_printf(JL_STDOUT, "call %s%s\n", - jl_sprint(args[0]), - jl_sprint((jl_value_t*)aty)); - }*/ - jl_lambda_info_t *li = jl_get_specialization1((jl_tupletype_t*)aty); - if (li != NULL && !li->inInference) { - jl_compile_linfo(li); - assert(li->functionObjectsDecls.functionObject != NULL); - theFptr = (Value*)li->functionObjectsDecls.functionObject; - jl_cgval_t fval; - if (f != NULL) { - // TODO jb/functions: avoid making too many roots here - if (!jl_is_globalref(args[0]) && !jl_is_symbol(args[0]) && - !jl_is_leaf_type(f)) { - if (ctx->linfo->def) - jl_add_linfo_root(ctx->linfo, f); - else // for toplevel thunks, just write the value back to the AST to root it - jl_array_ptr_set(ex->args, 0, f); - } - fval = mark_julia_const((jl_value_t*)f); - } - else { - fval = emit_expr(args[0], ctx); - } - if (ctx->linfo->def) // root this li in case it gets deleted from the cache in `f` - jl_add_linfo_root(ctx->linfo, (jl_value_t*)li); - result = emit_call_function_object(li, fval, theFptr, args, nargs, expr, ctx); - JL_GC_POP(); - return result; - } - } - } - // emit function and arguments nargs++; // add function to nargs count jl_cgval_t *anArg = (jl_cgval_t*)alloca(sizeof(jl_cgval_t) * nargs); diff --git a/test/inference.jl b/test/inference.jl index d15ee68205f4b5..05216b4786c83e 100644 --- a/test/inference.jl +++ b/test/inference.jl @@ -5,14 +5,14 @@ # issue 9770 @noinline x9770() = false function f9770(x) - if x9770() + return if x9770() g9770(:a, :foo) else x end end function g9770(x,y) - if isa(y, Symbol) + return if isa(y, Symbol) f9770(x) else g9770(:a, :foo) @@ -58,7 +58,7 @@ function g3182(t::DataType) # subtype of Type, but we cannot infer the T in Type{T} just # by knowing (at compile time) that the argument is a DataType. # however the ::Type{T} method should still match at run time. - f3182(t) + return f3182(t) end @test g3182(Complex) == 0 @@ -107,7 +107,7 @@ barTuple2() = fooTuple{tuple(:y)}() # issue #12476 function f12476(a) (k, v) = a - v + return v end @inferred f12476(1.0 => 1) @@ -143,14 +143,17 @@ f12826{I<:Integer}(v::Vector{I}) = v[1] # non-terminating inference, issue #14009 +# non-terminating codegen, issue #16201 type A14009{T}; end A14009{T}(a::T) = A14009{T}() f14009(a) = rand(Bool) ? f14009(A14009(a)) : a code_typed(f14009, (Int,)) +code_llvm(DevNull, f14009, (Int,)) type B14009{T}; end g14009(a) = g14009(B14009{a}) code_typed(g14009, (Type{Int},)) +code_llvm(DevNull, f14009, (Int,)) # issue #9232 @@ -164,6 +167,7 @@ result_type9232{T1<:Number,T2<:Number}(::Type{T1}, ::Type{T2}) = arithtype9232(T function g10878(x; kw...); end invoke_g10878() = invoke(g10878, Tuple{Any}, 1) @code_typed invoke_g10878() +code_llvm(DevNull, invoke_g10878, ()) # issue #10930