diff options
author | H.J. Lu <hongjiu.lu@intel.com> | 2008-07-18 15:48:04 +0000 |
---|---|---|
committer | H.J. Lu <hjl@gcc.gnu.org> | 2008-07-18 08:48:04 -0700 |
commit | c565a1e7b774b3a578f15ca865e5eb69aebc0820 (patch) | |
tree | c2c577487a8faefadd1df0441597ce049b27a9d8 /gcc/config/i386 | |
parent | 5ae53a2559819d1628193d5a3d9257029ebe1fe7 (diff) | |
download | gcc-c565a1e7b774b3a578f15ca865e5eb69aebc0820.zip gcc-c565a1e7b774b3a578f15ca865e5eb69aebc0820.tar.gz gcc-c565a1e7b774b3a578f15ca865e5eb69aebc0820.tar.bz2 |
re PR middle-end/36859 (Caller/callee mismatch for vararg on stack)
gcc/
2008-07-18 H.J. Lu <hongjiu.lu@intel.com>
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 <hongjiu.lu@intel.com>
PR middle-end/36859
* gcc.target/i386/vararg-2.c: New.
From-SVN: r137955
Diffstat (limited to 'gcc/config/i386')
-rw-r--r-- | gcc/config/i386/i386.c | 13 |
1 files changed, 11 insertions, 2 deletions
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); |