@@ -292,6 +292,7 @@ static Function *jlgetfield_func;
292
292
static Function *jlbox_func;
293
293
static Function *jlclosure_func;
294
294
static Function *jlmethod_func;
295
+ static Function *jlgenericfunction_func;
295
296
static Function *jlenter_func;
296
297
static Function *jlleave_func;
297
298
static Function *jlegal_func;
@@ -1478,8 +1479,10 @@ static void simple_escape_analysis(jl_value_t *expr, bool esc, jl_codectx_t *ctx
1478
1479
}
1479
1480
else if (e->head == method_sym) {
1480
1481
simple_escape_analysis (jl_exprarg (e,0 ), esc, ctx);
1481
- simple_escape_analysis (jl_exprarg (e,1 ), esc, ctx);
1482
- simple_escape_analysis (jl_exprarg (e,2 ), esc, ctx);
1482
+ if (jl_expr_nargs (e) > 1 ) {
1483
+ simple_escape_analysis (jl_exprarg (e,1 ), esc, ctx);
1484
+ simple_escape_analysis (jl_exprarg (e,2 ), esc, ctx);
1485
+ }
1483
1486
}
1484
1487
else if (e->head == assign_sym) {
1485
1488
// don't consider assignment LHS as a variable "use"
@@ -3121,16 +3124,22 @@ static Value *emit_expr(jl_value_t *expr, jl_codectx_t *ctx, bool isboxed,
3121
3124
}
3122
3125
}
3123
3126
}
3124
- Value *a1 = boxed (emit_expr (args[1 ], ctx),ctx);
3125
- make_gcroot (a1, ctx);
3126
- Value *a2 = boxed (emit_expr (args[2 ], ctx),ctx);
3127
- make_gcroot (a2, ctx);
3128
- Value *mdargs[9 ] =
3129
- { name, bp, bp_owner, literal_pointer_val (bnd), a1, a2, literal_pointer_val (args[3 ]),
3130
- literal_pointer_val ((jl_value_t *)jl_module_call_func (ctx->module )),
3131
- ConstantInt::get (T_int32, (int )iskw) };
3132
- ctx->argDepth = last_depth;
3133
- return builder.CreateCall (prepare_call (jlmethod_func), ArrayRef<Value*>(&mdargs[0 ], 9 ));
3127
+ if (jl_expr_nargs (ex) == 1 ) {
3128
+ Value *mdargs[4 ] = { name, bp, bp_owner, literal_pointer_val (bnd) };
3129
+ return builder.CreateCall (prepare_call (jlgenericfunction_func), ArrayRef<Value*>(&mdargs[0 ], 4 ));
3130
+ }
3131
+ else {
3132
+ Value *a1 = boxed (emit_expr (args[1 ], ctx),ctx);
3133
+ make_gcroot (a1, ctx);
3134
+ Value *a2 = boxed (emit_expr (args[2 ], ctx),ctx);
3135
+ make_gcroot (a2, ctx);
3136
+ Value *mdargs[9 ] =
3137
+ { name, bp, bp_owner, literal_pointer_val (bnd), a1, a2, literal_pointer_val (args[3 ]),
3138
+ literal_pointer_val ((jl_value_t *)jl_module_call_func (ctx->module )),
3139
+ ConstantInt::get (T_int32, (int )iskw) };
3140
+ ctx->argDepth = last_depth;
3141
+ return builder.CreateCall (prepare_call (jlmethod_func), ArrayRef<Value*>(&mdargs[0 ], 9 ));
3142
+ }
3134
3143
}
3135
3144
else if (head == const_sym) {
3136
3145
jl_sym_t *sym = (jl_sym_t *)args[0 ];
@@ -5200,6 +5209,17 @@ static void init_julia_llvm_env(Module *m)
5200
5209
" jl_method_def" , m);
5201
5210
add_named_global (jlmethod_func, (void *)&jl_method_def);
5202
5211
5212
+ std::vector<Type*> funcdefargs (0 );
5213
+ funcdefargs.push_back (jl_pvalue_llvmt);
5214
+ funcdefargs.push_back (jl_ppvalue_llvmt);
5215
+ funcdefargs.push_back (jl_pvalue_llvmt);
5216
+ funcdefargs.push_back (jl_pvalue_llvmt);
5217
+ jlgenericfunction_func =
5218
+ Function::Create (FunctionType::get (jl_pvalue_llvmt, funcdefargs, false ),
5219
+ Function::ExternalLinkage,
5220
+ " jl_generic_function_def" , m);
5221
+ add_named_global (jlgenericfunction_func, (void *)&jl_generic_function_def);
5222
+
5203
5223
std::vector<Type*> ehargs (0 );
5204
5224
ehargs.push_back (T_pint8);
5205
5225
jlenter_func =
0 commit comments