+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.
+
2008-07-18 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/36858
type = build_pointer_type (type);
align = PARM_BOUNDARY / BITS_PER_UNIT;
- boundary = FUNCTION_ARG_BOUNDARY (TYPE_MODE (type), type) / BITS_PER_UNIT;
+ boundary = FUNCTION_ARG_BOUNDARY (TYPE_MODE (type), type);
+
+ /* 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. */
+ if (boundary > PREFERRED_STACK_BOUNDARY)
+ boundary = PREFERRED_STACK_BOUNDARY;
+
+ boundary /= BITS_PER_UNIT;
/* Hoist the valist value into a temporary for the moment. */
valist_tmp = get_initialized_tmp_var (valist, pre_p, NULL);
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)))
/* ... 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);
+2008-07-18 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR middle-end/36859
+ * gcc.target/i386/vararg-2.c: New.
+
2008-07-18 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/36858
--- /dev/null
+/* PR middle-end/36859 */
+/* { dg-do run } */
+/* { dg-options "-w" { target { lp64 } } } */
+/* { dg-options "-w -msse2 -mpreferred-stack-boundary=2" { target { ilp32 } } } */
+
+#include "sse2-check.h"
+#include <stdarg.h>
+#include <emmintrin.h>
+
+__m128
+__attribute__((noinline))
+test (int a, ...)
+{
+ __m128 x;
+ va_list va_arglist;
+
+ va_start (va_arglist, a);
+ x = va_arg (va_arglist, __m128);
+ va_end (va_arglist);
+ return x;
+}
+
+__m128 n1 = { -283.3, -23.3, 213.4, 1119.03 };
+
+int
+__attribute__((noinline))
+foo (void)
+{
+ __m128 x = test (1, n1);
+ if (__builtin_memcmp (&x, &n1, sizeof (x)) != 0)
+ abort ();
+ return 0;
+}
+
+static void
+__attribute__((noinline))
+sse2_test (void)
+{
+ foo ();
+}