# HG changeset patch # User Michael Pavone # Date 1448650093 28800 # Node ID dc71e32091d84c3ef63462c014bd411eabfa857f # Parent 30efd12b1be139cab5f0f1b4ad0186ce1eefa893 Adjust stack before pushing arguments. Fixes new stack alignment code on 32-bit targets diff -r 30efd12b1be1 -r dc71e32091d8 gen_x86.c --- a/gen_x86.c Fri Nov 27 10:47:35 2015 -0800 +++ b/gen_x86.c Fri Nov 27 10:48:13 2015 -0800 @@ -2111,18 +2111,18 @@ #else #define stack_args num_args #endif - for (int i = stack_args -1; i >= 0; i--) - { - push_r(code, arg_arr[i]); - } - uint32_t stack_off_call = code->stack_off + sizeof(void *); + uint32_t stack_off_call = code->stack_off + sizeof(void *) * (stack_args + 1); uint32_t adjust = 0; if (stack_off_call & 0xF) { adjust = 16 - (stack_off_call & 0xF); sub_ir(code, adjust, RSP, SZ_PTR); code->stack_off += adjust; } - + for (int i = stack_args -1; i >= 0; i--) + { + push_r(code, arg_arr[i]); + } + return stack_args * sizeof(void *) + adjust; }