i386: Set cfun->machine->max_used_stack_alignment if needed

cfun->machine->max_used_stack_alignment is used to decide how stack frame
should be aligned.  This is independent of any psABIs nor 32-bit vs 64-bit.
It is always safe to compute max_used_stack_alignment.  We compute it only
if 128-bit aligned load/store may be generated on misaligned stack slot
which will lead to segfault.

gcc/

	PR target/86386
	* config/i386/i386.c (ix86_finalize_stack_frame_flags): Set
	cfun->machine->max_used_stack_alignment if needed.

gcc/testsuite/

	PR target/86386
	* gcc.target/i386/pr86386.c: New file.

From-SVN: r263317
This commit is contained in:
H.J. Lu 2018-08-05 12:46:13 +00:00 committed by H.J. Lu
parent 7ff1e4e9c0
commit 91539305a8
4 changed files with 44 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2018-08-05 H.J. Lu <hongjiu.lu@intel.com>
PR target/86386
* config/i386/i386.c (ix86_finalize_stack_frame_flags): Set
cfun->machine->max_used_stack_alignment if needed.
2018-08-04 Martin Sebor <msebor@redhat.com>
PR tree-optimization/86571

View File

@ -13281,12 +13281,14 @@ ix86_finalize_stack_frame_flags (void)
recompute_frame_layout_p = true;
}
}
else if (crtl->max_used_stack_slot_alignment
> crtl->preferred_stack_boundary)
else if (crtl->max_used_stack_slot_alignment >= 128)
{
/* We don't need to realign stack. But we still need to keep
stack frame properly aligned to satisfy the largest alignment
of stack slots. */
/* We don't need to realign stack. max_used_stack_alignment is
used to decide how stack frame should be aligned. This is
independent of any psABIs nor 32-bit vs 64-bit. It is always
safe to compute max_used_stack_alignment. We compute it only
if 128-bit aligned load/store may be generated on misaligned
stack slot which will lead to segfault. */
if (ix86_find_max_used_stack_alignment (stack_alignment, true))
cfun->machine->max_used_stack_alignment
= stack_alignment / BITS_PER_UNIT;

View File

@ -1,3 +1,8 @@
2018-08-05 H.J. Lu <hongjiu.lu@intel.com>
PR target/86386
* gcc.target/i386/pr86386.c: New file.
2018-08-04 Tom de Vries <tdevries@suse.de>
* lib/gcc-gdb-test.exp: Use absolute line number in pass/fail line.

View File

@ -0,0 +1,26 @@
/* PR target/86386 */
/* { dg-do run { target { avx_runtime && int128 } } } */
/* { dg-options "-Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx" } */
unsigned c, d, e, f;
unsigned __attribute__((noipa))
foo (unsigned char g, unsigned short h, unsigned i, unsigned long long j,
unsigned char k, unsigned short l, unsigned m, unsigned __int128 n)
{
__builtin_memset (&e, 0, 3);
n <<= m;
__builtin_memcpy (&m, 2 + (char *) &n, 1);
m >>= 0;
d ^= __builtin_mul_overflow (l, n, &m);
return m;
}
int
main ()
{
unsigned __int128 x = foo (0, 0, 0, 0, 0, 4, 1, 3);
if (x != 24)
__builtin_abort ();
return 0;
}