From 762a7279a40e4eababa14b29b704e7d057b6f347 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Thu, 14 Aug 2014 12:15:22 -0400 Subject: [PATCH] (broken) patch to eliminate emit_func_check --- src/cgutils.cpp | 23 ----------------------- src/codegen.cpp | 14 ++++++-------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/cgutils.cpp b/src/cgutils.cpp index b341b84ee81fe..ba5f9b264c5d3 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -824,29 +824,6 @@ static Value *emit_bounds_check(Value *i, Value *len, jl_codectx_t *ctx) return im1; } -static void emit_func_check(Value *x, jl_codectx_t *ctx) -{ - Value *xty = emit_typeof(x); - Value *isfunc = - builder. - CreateOr(builder. - CreateICmpEQ(xty, - literal_pointer_val((jl_value_t*)jl_function_type)), - builder. - CreateICmpEQ(xty, - literal_pointer_val((jl_value_t*)jl_datatype_type))); - BasicBlock *elseBB1 = BasicBlock::Create(getGlobalContext(),"notf", ctx->f); - BasicBlock *mergeBB1 = BasicBlock::Create(getGlobalContext(),"isf"); - builder.CreateCondBr(isfunc, mergeBB1, elseBB1); - - builder.SetInsertPoint(elseBB1); - emit_type_error(x, (jl_value_t*)jl_function_type, "apply", ctx); - - builder.CreateBr(mergeBB1); - ctx->f->getBasicBlockList().push_back(mergeBB1); - builder.SetInsertPoint(mergeBB1); -} - // --- loading and storing --- static Value *emit_nthptr_addr(Value *v, size_t n) diff --git a/src/codegen.cpp b/src/codegen.cpp index a2348f7b1e01a..5c33908080823 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -2219,8 +2219,12 @@ static Value *emit_call(jl_value_t **args, size_t arglen, jl_codectx_t *ctx, if (theFptr == NULL) { specialized = false; Value *theFunc = emit_expr(args[0], ctx); - if (theFunc->getType() != jl_pvalue_llvmt || jl_is_tuple(hdtype)) { - // we know it's not a function + if ((hdtype!=(jl_value_t*)jl_function_type && + hdtype!=(jl_value_t*)jl_datatype_type && + !(jl_is_type_type(hdtype) && + jl_is_datatype(jl_tparam0(hdtype)))) || + jl_is_tuple(hdtype) || theFunc->getType() != jl_pvalue_llvmt) { + // it may not be a function, use call(f, ...) instead headIsGlobal = true; Value *result = emit_known_call((jl_value_t*)jl_call_func, --args, ++nargs, ctx, @@ -2234,12 +2238,6 @@ static Value *emit_call(jl_value_t **args, size_t arglen, jl_codectx_t *ctx, make_gcroot(boxed(theFunc,ctx), ctx); } #endif - if (hdtype!=(jl_value_t*)jl_function_type && - hdtype!=(jl_value_t*)jl_datatype_type && - !(jl_is_type_type(hdtype) && - jl_is_datatype(jl_tparam0(hdtype)))) { - emit_func_check(theFunc, ctx); - } // extract pieces of the function object // TODO: try extractvalue instead theFptr = builder.CreateBitCast(emit_nthptr(theFunc, 1, tbaa_func), jl_fptr_llvmt);