mirror of
https://github.com/danog/ir.git
synced 2024-11-30 04:39:43 +01:00
Fix CALL/1 copying. Fallback to CALL+RETURN when we can't generate code for TAILCALL.
This commit is contained in:
parent
a165c43196
commit
ef3ffff81b
@ -3589,7 +3589,14 @@ static void ir_emit_tailcall(ir_ctx *ctx, ir_ref def, ir_insn *insn)
|
||||
dasm_State **Dst = &data->dasm_state;
|
||||
int32_t used_stack = ir_emit_arguments(ctx, def, insn, ctx->regs[def][1]);
|
||||
|
||||
IR_ASSERT(used_stack == 0);
|
||||
if (used_stack != 0) {
|
||||
ir_emit_call(ctx, def, insn);
|
||||
if (ctx->flags & IR_FUNCTION) {
|
||||
ir_emit_epilogue(ctx);
|
||||
}
|
||||
ir_emit_return_void(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
ir_emit_epilogue(ctx);
|
||||
|
||||
|
2
ir_gcm.c
2
ir_gcm.c
@ -269,7 +269,7 @@ static int ir_copy(ir_ctx *new_ctx, ir_ctx *ctx, ir_ref *_next, bool preserve_co
|
||||
insn = &ctx->ir_base[i];
|
||||
flags = ir_op_flags[insn->op];
|
||||
n = ir_operands_count(ctx, insn);
|
||||
if ((insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN) && n != 2) {
|
||||
if ((insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN || insn->op == IR_CALL || insn->op == IR_TAILCALL) && n != 2) {
|
||||
new_ref = ir_emit_N(new_ctx, insn->opt, n);
|
||||
} else if (n <= 3) {
|
||||
new_ref = ir_emit0(new_ctx, insn->opt);
|
||||
|
@ -5406,7 +5406,14 @@ static void ir_emit_tailcall(ir_ctx *ctx, ir_ref def, ir_insn *insn)
|
||||
int32_t used_stack = ir_emit_arguments(ctx, def, insn, ctx->regs[def][1]);
|
||||
(void) used_stack;
|
||||
|
||||
IR_ASSERT(used_stack == 0);
|
||||
if (used_stack != 0) {
|
||||
ir_emit_call(ctx, def, insn);
|
||||
if (ctx->flags & IR_FUNCTION) {
|
||||
ir_emit_epilogue(ctx);
|
||||
}
|
||||
ir_emit_return_void(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx->flags & IR_FUNCTION) {
|
||||
ir_emit_epilogue(ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user