@@ -352,6 +352,7 @@ static Function *jlthrow_func;
352
352
static Function *jlerror_func;
353
353
static Function *jltypeerror_func;
354
354
static Function *jlundefvarerror_func;
355
+ static Function *jlambiguouserror_func;
355
356
static Function *jlboundserror_func;
356
357
static Function *jluboundserror_func;
357
358
static Function *jlvboundserror_func;
@@ -1094,7 +1095,7 @@ void *jl_get_llvmf(jl_tupletype_t *tt, bool getwrapper, bool getdeclarations)
1094
1095
jl_lambda_info_t *linfo = NULL ;
1095
1096
JL_GC_PUSH2 (&linfo, &tt);
1096
1097
if (tt != NULL ) {
1097
- linfo = jl_get_specialization1 (tt);
1098
+ linfo = jl_checked_specialization1 (tt);
1098
1099
if (linfo == NULL ) {
1099
1100
jl_typemap_entry_t *entry;
1100
1101
linfo = jl_method_lookup_by_type (
@@ -1103,7 +1104,6 @@ void *jl_get_llvmf(jl_tupletype_t *tt, bool getwrapper, bool getdeclarations)
1103
1104
JL_GC_POP ();
1104
1105
return NULL ;
1105
1106
}
1106
- check_ambig_call (linfo->def , tt);
1107
1107
}
1108
1108
}
1109
1109
if (linfo == NULL ) {
@@ -2687,6 +2687,19 @@ static jl_cgval_t emit_call_function_object(jl_lambda_info_t *li, const jl_cgval
2687
2687
expr_type (callexpr, ctx), ctx);
2688
2688
}
2689
2689
2690
+ static void emit_ambiguous_call_error (jl_tupletype_t *tt, jl_array_t *ambiguities, jl_codectx_t *ctx)
2691
+ {
2692
+ // builder.SetInsertPoint(err);
2693
+ #ifdef LLVM37
2694
+ builder.CreateCall (prepare_call (jlambiguouserror_func), { literal_pointer_val ((jl_value_t *)tt), literal_pointer_val ((jl_value_t *)ambiguities) });
2695
+ #else
2696
+ builder.CreateCall2 (prepare_call (jlambiguouserror_func), literal_pointer_val ((jl_value_t *)tt), literal_pointer_val ((jl_value_t *)ambiguities));
2697
+ #endif
2698
+ builder.CreateUnreachable ();
2699
+ BasicBlock *cont = BasicBlock::Create (jl_LLVMContext," after_error" ,ctx->f );
2700
+ builder.SetInsertPoint (cont);
2701
+ }
2702
+
2690
2703
static jl_cgval_t emit_call (jl_expr_t *ex, jl_codectx_t *ctx)
2691
2704
{
2692
2705
jl_value_t *expr = (jl_value_t *)ex;
@@ -2696,9 +2709,10 @@ static jl_cgval_t emit_call(jl_expr_t *ex, jl_codectx_t *ctx)
2696
2709
Value *theFptr = NULL ;
2697
2710
jl_cgval_t result;
2698
2711
jl_value_t *aty = NULL ;
2712
+ jl_value_t *ambiguities = NULL ;
2699
2713
2700
2714
jl_function_t *f = (jl_function_t *)static_eval (args[0 ], ctx, true );
2701
- JL_GC_PUSH2 (&f, &aty);
2715
+ JL_GC_PUSH3 (&f, &aty, &ambiguities );
2702
2716
if (f != NULL ) {
2703
2717
// function is a compile-time constant
2704
2718
if (jl_typeis (f, jl_intrinsic_type)) {
@@ -2738,30 +2752,39 @@ static jl_cgval_t emit_call(jl_expr_t *ex, jl_codectx_t *ctx)
2738
2752
jl_sprint(args[0]),
2739
2753
jl_sprint((jl_value_t*)aty));
2740
2754
}*/
2741
- jl_lambda_info_t *li = jl_get_specialization1 ((jl_tupletype_t *)aty);
2755
+ jl_typemap_entry_t *entry;
2756
+ jl_lambda_info_t *li = jl_get_specialization1 ((jl_tupletype_t *)aty, &entry);
2742
2757
if (li != NULL ) {
2743
- assert (li->functionObjectsDecls .functionObject != NULL );
2744
- theFptr = (Value*)li->functionObjectsDecls .functionObject ;
2745
- jl_cgval_t fval;
2746
- if (f != NULL ) {
2747
- // TODO jb/functions: avoid making too many roots here
2748
- if (!jl_is_globalref (args[0 ]) && !jl_is_symbol (args[0 ]) &&
2749
- !jl_is_leaf_type (f)) {
2750
- if (ctx->linfo ->def )
2751
- jl_add_linfo_root (ctx->linfo , f);
2752
- else // for toplevel thunks, just write the value back to the AST to root it
2753
- jl_cellset (ex->args , 0 , f);
2754
- }
2755
- fval = mark_julia_const ((jl_value_t *)f);
2758
+ jl_method_t *m = li->def ;
2759
+ ambiguities = jl_list_call_ambiguities_ ((jl_tupletype_t *)aty, m);
2760
+ if (ambiguities != jl_nothing) {
2761
+ emit_ambiguous_call_error ((jl_tupletype_t *)aty,
2762
+ (jl_array_t *)ambiguities, ctx);
2756
2763
}
2757
2764
else {
2758
- fval = emit_expr (args[0 ], ctx);
2765
+ assert (li->functionObjectsDecls .functionObject != NULL );
2766
+ theFptr = (Value*)li->functionObjectsDecls .functionObject ;
2767
+ jl_cgval_t fval;
2768
+ if (f != NULL ) {
2769
+ // TODO jb/functions: avoid making too many roots here
2770
+ if (!jl_is_globalref (args[0 ]) && !jl_is_symbol (args[0 ]) &&
2771
+ !jl_is_leaf_type (f)) {
2772
+ if (ctx->linfo ->def )
2773
+ jl_add_linfo_root (ctx->linfo , f);
2774
+ else // for toplevel thunks, just write the value back to the AST to root it
2775
+ jl_cellset (ex->args , 0 , f);
2776
+ }
2777
+ fval = mark_julia_const ((jl_value_t *)f);
2778
+ }
2779
+ else {
2780
+ fval = emit_expr (args[0 ], ctx);
2781
+ }
2782
+ if (ctx->linfo ->def ) // root this li in case it gets deleted from the cache in `f`
2783
+ jl_add_linfo_root (ctx->linfo , (jl_value_t *)li);
2784
+ result = emit_call_function_object (li, fval, theFptr, args, nargs, expr, ctx);
2785
+ JL_GC_POP ();
2786
+ return result;
2759
2787
}
2760
- if (ctx->linfo ->def ) // root this li in case it gets deleted from the cache in `f`
2761
- jl_add_linfo_root (ctx->linfo , (jl_value_t *)li);
2762
- result = emit_call_function_object (li, fval, theFptr, args, nargs, expr, ctx);
2763
- JL_GC_POP ();
2764
- return result;
2765
2788
}
2766
2789
}
2767
2790
}
@@ -3520,7 +3543,7 @@ static Function *gen_cfun_wrapper(jl_function_t *ff, jl_value_t *jlrettype, jl_t
3520
3543
jl_error (" va_arg syntax not allowed for cfunction argument list" );
3521
3544
3522
3545
const char *name = " cfunction" ;
3523
- jl_lambda_info_t *lam = jl_get_specialization1 ((jl_tupletype_t *)sigt);
3546
+ jl_lambda_info_t *lam = jl_checked_specialization1 ((jl_tupletype_t *)sigt);
3524
3547
jl_value_t *astrt = (jl_value_t *)jl_any_type;
3525
3548
if (lam != NULL ) {
3526
3549
name = jl_symbol_name (lam->def ->name );
@@ -5198,6 +5221,16 @@ static void init_julia_llvm_env(Module *m)
5198
5221
jlundefvarerror_func->setDoesNotReturn ();
5199
5222
add_named_global (jlundefvarerror_func, &jl_undefined_var_error);
5200
5223
5224
+ std::vector<Type*> args2_ambiguouserror (0 );
5225
+ args2_ambiguouserror.push_back (T_pjlvalue);
5226
+ args2_ambiguouserror.push_back (T_pjlvalue);
5227
+ jlambiguouserror_func =
5228
+ Function::Create (FunctionType::get (T_void, args2_ambiguouserror, false ),
5229
+ Function::ExternalLinkage,
5230
+ " jl_ambiguous_call_error" , m);
5231
+ jlambiguouserror_func->setDoesNotReturn ();
5232
+ add_named_global (jlambiguouserror_func, &jl_ambiguous_call_error);
5233
+
5201
5234
std::vector<Type*> args2_boundserrorv (0 );
5202
5235
args2_boundserrorv.push_back (T_pjlvalue);
5203
5236
args2_boundserrorv.push_back (T_psize);
0 commit comments