------- Comment #31 from ubizjak at gmail dot com 2008-02-14 12:48 ------- (In reply to comment #30)
> participate to the discussion, but I think this PR only expose an underlying > bug that should be analyzed. > > From what I understand, if *STACK_BOUNDARY is larger than the size of what is > pushed in the stack, some padding is performed. So the basic question is why > this done for -O2 and not for -Os. Well, _if_ we want STACK_BOUNDARY larger than PARM_BOUNDARY, then following patch is needed: ndex: function.c =================================================================== --- function.c (revision 132313) +++ function.c (working copy) @@ -3436,7 +3436,7 @@ pad_to_arg_alignment (struct args_size * sp_offset = 0; #endif - if (boundary > PARM_BOUNDARY && boundary > STACK_BOUNDARY) + if (boundary > PARM_BOUNDARY || boundary > STACK_BOUNDARY) { save_var = offset_ptr->var; save_constant = offset_ptr->constant; @@ -3462,7 +3462,7 @@ pad_to_arg_alignment (struct args_size * offset_ptr->var = size_binop (MINUS_EXPR, rounded, sp_offset_tree); /* ARGS_SIZE_TREE includes constant term. */ offset_ptr->constant = 0; - if (boundary > PARM_BOUNDARY && boundary > STACK_BOUNDARY) + if (boundary > PARM_BOUNDARY || boundary > STACK_BOUNDARY) alignment_pad->var = size_binop (MINUS_EXPR, offset_ptr->var, save_var); } @@ -3474,7 +3474,7 @@ pad_to_arg_alignment (struct args_size * #else CEIL_ROUND (offset_ptr->constant + sp_offset, boundary_in_bytes); #endif - if (boundary > PARM_BOUNDARY && boundary > STACK_BOUNDARY) + if (boundary > PARM_BOUNDARY || boundary > STACK_BOUNDARY) alignment_pad->constant = offset_ptr->constant - save_constant; } } This patch fixes va-arg-25.c testcase I'm testing with STACK_BOUNDARY = 128. The patch bootstraps and regression tests on i686-pc-linux-gnu, but due to STACK_BOUNDARY == PARM_BOUNDARY on this target, it has not much effect there. Without this patch, alignment pad is always 0, which is just wrong for va-arg-25.c case with mixed int/SSE/int/SSE arguments pushed on stack. Note that sse requires 16 byte alignment. Using -maccumulate-outgoing-args (-O2), we subtract %esp and stick arguments into the call frame using offseted moves. We have no other %esp manipulation in this case. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34621