Skip to content

Commit 8ea2ad7

Browse files
committed
Merge pull request #12676 from JuliaLang/jn/compile_all_fixes2
more fixes for --compile=all
2 parents 6ae7707 + 841ddc0 commit 8ea2ad7

File tree

2 files changed

+24
-29
lines changed

2 files changed

+24
-29
lines changed

src/codegen.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3889,6 +3889,8 @@ static Function *emit_function(jl_lambda_info_t *lam)
38893889
size_t captvinfoslen = jl_array_dim0(captvinfos);
38903890
size_t nreq = largslen;
38913891
int va = 0;
3892+
if (!lam->specTypes)
3893+
lam->specTypes = jl_anytuple_type;
38923894
if (nreq > 0 && jl_is_rest_arg(jl_cellref(largs,nreq-1))) {
38933895
nreq--;
38943896
va = 1;
@@ -3955,7 +3957,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
39553957
Function *f = NULL;
39563958

39573959
bool specsig = false;
3958-
if (!va && !hasCapt && lam->specTypes != NULL && lam->inferred) {
3960+
if (!va && !hasCapt && lam->specTypes != jl_anytuple_type && lam->inferred) {
39593961
// no captured vars and not vararg
39603962
// consider specialized signature
39613963
for(size_t i=0; i < jl_nparams(lam->specTypes); i++) {
@@ -4416,37 +4418,30 @@ static Function *emit_function(jl_lambda_info_t *lam)
44164418
}
44174419

44184420
// step 11. check arg count
4419-
if (ctx.linfo->specTypes == NULL) {
4421+
if (jl_is_va_tuple(ctx.linfo->specTypes)) {
4422+
std::string msg;
4423+
Value *enough;
44204424
if (va) {
4421-
Value *enough =
4422-
builder.CreateICmpUGE(argCount,
4425+
msg = "too few arguments";
4426+
enough = builder.CreateICmpUGE(argCount,
44234427
ConstantInt::get(T_int32, nreq));
4424-
BasicBlock *elseBB =
4425-
BasicBlock::Create(getGlobalContext(), "else", f);
4426-
BasicBlock *mergeBB =
4427-
BasicBlock::Create(getGlobalContext(), "ifcont");
4428-
builder.CreateCondBr(enough, mergeBB, elseBB);
4429-
builder.SetInsertPoint(elseBB);
4430-
just_emit_error("too few arguments", &ctx);
4431-
builder.CreateUnreachable();
4432-
f->getBasicBlockList().push_back(mergeBB);
4433-
builder.SetInsertPoint(mergeBB);
44344428
}
44354429
else {
4436-
Value *enough =
4430+
msg = "wrong number of arguments";
4431+
enough =
44374432
builder.CreateICmpEQ(argCount,
44384433
ConstantInt::get(T_int32, nreq));
4439-
BasicBlock *elseBB =
4440-
BasicBlock::Create(getGlobalContext(), "else", f);
4441-
BasicBlock *mergeBB =
4442-
BasicBlock::Create(getGlobalContext(), "ifcont");
4443-
builder.CreateCondBr(enough, mergeBB, elseBB);
4444-
builder.SetInsertPoint(elseBB);
4445-
just_emit_error("wrong number of arguments", &ctx);
4446-
builder.CreateUnreachable();
4447-
f->getBasicBlockList().push_back(mergeBB);
4448-
builder.SetInsertPoint(mergeBB);
44494434
}
4435+
BasicBlock *elseBB =
4436+
BasicBlock::Create(getGlobalContext(), "else", f);
4437+
BasicBlock *mergeBB =
4438+
BasicBlock::Create(getGlobalContext(), "ifcont");
4439+
builder.CreateCondBr(enough, mergeBB, elseBB);
4440+
builder.SetInsertPoint(elseBB);
4441+
just_emit_error(msg, &ctx);
4442+
builder.CreateUnreachable();
4443+
f->getBasicBlockList().push_back(mergeBB);
4444+
builder.SetInsertPoint(mergeBB);
44504445
}
44514446

44524447
// step 12. move args into local variables

src/gf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,16 +1499,16 @@ static void all_p2c(jl_value_t *ast, jl_svec_t *tvars)
14991499

15001500
static void precompile_unspecialized(jl_function_t *func, jl_tupletype_t *sig, jl_svec_t *tvars)
15011501
{
1502+
assert(sig);
15021503
func->linfo->specTypes = sig;
1503-
if (sig)
1504-
jl_gc_wb(func->linfo, sig);
1504+
jl_gc_wb(func->linfo, sig);
15051505
if (tvars != jl_emptysvec) {
15061506
// add static parameter names to end of closure env; compile
15071507
// assuming they are there. method cache will fill them in when
15081508
// it constructs closures for new "specializations".
15091509
all_p2c((jl_value_t*)func->linfo, tvars);
15101510
}
1511-
jl_trampoline_compile_function(func, 1, sig ? sig : jl_anytuple_type);
1511+
jl_trampoline_compile_function(func, 1, sig);
15121512
}
15131513

15141514
void jl_compile_all_defs(jl_function_t *gf)
@@ -1576,7 +1576,7 @@ static void _compile_all(jl_module_t *m, htable_t *h)
15761576
li->unspecialized = func;
15771577
jl_gc_wb(li, func);
15781578
}
1579-
precompile_unspecialized(func, NULL, jl_emptysvec);
1579+
precompile_unspecialized(func, li->specTypes ? li->specTypes : jl_anytuple_type, jl_emptysvec);
15801580
}
15811581
}
15821582
}

0 commit comments

Comments
 (0)