From af237c51394ca4694279f8c4d31c8f436d47f201 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sat, 24 Nov 2012 10:51:50 +0100 Subject: [PATCH] beabi: Use the stack alignment, instead of hardcoding 4, to align the frame size. --- ir/be/beabi.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ir/be/beabi.c b/ir/be/beabi.c index a2fc060ed..be28e76a0 100644 --- a/ir/be/beabi.c +++ b/ir/be/beabi.c @@ -1394,7 +1394,6 @@ static void modify_irg(ir_graph *const irg, be_abi_irg_t *const env) int n_params; int i, n; unsigned j; - unsigned frame_size; reg_node_map_t *rm; const arch_register_t *fp_reg; @@ -1423,11 +1422,10 @@ static void modify_irg(ir_graph *const irg, be_abi_irg_t *const env) default_layout_compound_type(frame_tp); } - /* align stackframe to 4 byte */ - frame_size = get_type_size_bytes(frame_tp); - if (frame_size % 4 != 0) { - set_type_size_bytes(frame_tp, frame_size + 4 - (frame_size % 4)); - } + /* align stackframe */ + unsigned const alignment = 1U << arch_env->stack_alignment; + unsigned const frame_size = round_up2(get_type_size_bytes(frame_tp), alignment); + set_type_size_bytes(frame_tp, frame_size); env->regs = pmap_create(); -- 2.20.1