From c565a1e7b774b3a578f15ca865e5eb69aebc0820 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 18 Jul 2008 15:48:04 +0000 Subject: re PR middle-end/36859 (Caller/callee mismatch for vararg on stack) gcc/ 2008-07-18 H.J. Lu PR middle-end/36859 * builtins.c (std_gimplify_va_arg_expr): Limit alignment to PREFERRED_STACK_BOUNDARY. * config/i386/i386.c (ix86_gimplify_va_arg): Likewise. testsuite/ 2008-07-18 H.J. Lu PR middle-end/36859 * gcc.target/i386/vararg-2.c: New. From-SVN: r137955 --- gcc/config/i386/i386.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'gcc/config/i386') diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b63deb8..d910bd2 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5511,6 +5511,7 @@ ix86_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) int indirect_p = 0; tree ptrtype; enum machine_mode nat_mode; + int arg_boundary; /* Only 64bit target needs something special. */ if (!TARGET_64BIT || is_va_list_char_pointer (TREE_TYPE (valist))) @@ -5709,13 +5710,21 @@ ix86_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) /* ... otherwise out of the overflow area. */ + /* When we align parameter on stack for caller, if the parameter + alignment is beyond PREFERRED_STACK_BOUNDARY, it will be + aligned at PREFERRED_STACK_BOUNDARY. We will match callee + here with caller. */ + arg_boundary = FUNCTION_ARG_BOUNDARY (VOIDmode, type); + if ((unsigned int) arg_boundary > PREFERRED_STACK_BOUNDARY) + arg_boundary = PREFERRED_STACK_BOUNDARY; + /* Care for on-stack alignment if needed. */ - if (FUNCTION_ARG_BOUNDARY (VOIDmode, type) <= 64 + if (arg_boundary <= 64 || integer_zerop (TYPE_SIZE (type))) t = ovf; else { - HOST_WIDE_INT align = FUNCTION_ARG_BOUNDARY (VOIDmode, type) / 8; + HOST_WIDE_INT align = arg_boundary / 8; t = build2 (POINTER_PLUS_EXPR, TREE_TYPE (ovf), ovf, size_int (align - 1)); t = fold_convert (sizetype, t); -- cgit v1.1