mirror of
https://github.com/danog/ir.git
synced 2024-11-30 04:39:43 +01:00
We can't preallocate stack for fastcall function calls
This commit is contained in:
parent
58ba18bb7d
commit
038b1e43cd
@ -4748,9 +4748,11 @@ static void ir_preallocate_call_stack(ir_ctx *ctx, ir_backend_data *data)
|
||||
i += n;
|
||||
insn += n;
|
||||
}
|
||||
if (peak_call_stack_size) {
|
||||
data->call_stack_size = peak_call_stack_size;
|
||||
ctx->flags |= IR_PREALLOCATED_STACK;
|
||||
}
|
||||
}
|
||||
|
||||
static void ir_calc_stack_frame_size(ir_ctx *ctx, ir_backend_data *data)
|
||||
{
|
||||
|
15
ir_x86.dasc
15
ir_x86.dasc
@ -5780,7 +5780,12 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
|
||||
}
|
||||
#endif
|
||||
|
||||
if (insn->op == IR_CALL && (ctx->flags & IR_PREALLOCATED_STACK)) {
|
||||
if (insn->op == IR_CALL
|
||||
&& (ctx->flags & IR_PREALLOCATED_STACK)
|
||||
#ifdef IR_HAVE_FASTCALL
|
||||
&& !ir_is_fastcall(ctx, insn) /* fast call functions restore stack pointer */
|
||||
#endif
|
||||
) {
|
||||
// TODO: support for preallocated stack
|
||||
used_stack = 0;
|
||||
} else {
|
||||
@ -7332,7 +7337,11 @@ static void ir_preallocate_call_stack(ir_ctx *ctx, ir_backend_data *data)
|
||||
for (i = 1, insn = ctx->ir_base + 1; i < ctx->insns_count;) {
|
||||
if (insn->op == IR_CALL) {
|
||||
call_stack_size = ir_call_used_stack(ctx, insn);
|
||||
if (call_stack_size > peak_call_stack_size) {
|
||||
if (call_stack_size > peak_call_stack_size
|
||||
#ifdef IR_HAVE_FASTCALL
|
||||
&& (!ir_is_fastcall(ctx, insn) || !call_stack_size) /* fast call functions restore stack pointer */
|
||||
#endif
|
||||
) {
|
||||
peak_call_stack_size = call_stack_size;
|
||||
}
|
||||
}
|
||||
@ -7341,9 +7350,11 @@ static void ir_preallocate_call_stack(ir_ctx *ctx, ir_backend_data *data)
|
||||
i += n;
|
||||
insn += n;
|
||||
}
|
||||
if (peak_call_stack_size) {
|
||||
data->call_stack_size = peak_call_stack_size;
|
||||
ctx->flags |= IR_PREALLOCATED_STACK;
|
||||
}
|
||||
}
|
||||
|
||||
static void ir_calc_stack_frame_size(ir_ctx *ctx, ir_backend_data *data)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user