x86: Don't use get_frame_size when finalizing stack frame
authorH.J. Lu <hongjiu.lu@intel.com>
Fri, 14 Dec 2018 12:38:04 +0000 (12:38 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Fri, 14 Dec 2018 12:38:04 +0000 (04:38 -0800)
get_frame_size () returns used stack slots during compilation, which
may be optimized out later.  Since ix86_find_max_used_stack_alignment
is called by ix86_finalize_stack_frame_flags to check if stack frame
is required, there is no need to call get_frame_size () which may give
inaccurate final stack frame size.

Tested on AVX512 machine configured with

--with-arch=native --with-cpu=native

gcc/

PR target/88483
* config/i386/i386.c (ix86_finalize_stack_frame_flags): Don't
use get_frame_size ().

gcc/testsuite/

PR target/88483
* gcc.target/i386/stackalign/pr88483.c: New test.

From-SVN: r267133

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/stackalign/pr88483.c [new file with mode: 0644]

index 3d4a9e5f8ba307cca7421afaf0e6e079d7e14b8d..e5c226498aec75210bbd946ddafd5697db0e0ca9 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/88483
+       * config/i386/i386.c (ix86_finalize_stack_frame_flags): Don't
+       use get_frame_size ().
+
 2018-12-14  Andrew Stubbs  <ams@codesourcery.com>
 
        * gcc/lra-int.h (lra_register_new_scratch_op): Add third parameter.
index caa701fe24245aef8cbb1546d434edf029ec93f9..edc8f4f092eb14d5a71df54d76e7bfaae246677e 100644 (file)
@@ -12876,7 +12876,6 @@ ix86_finalize_stack_frame_flags (void)
           && flag_exceptions
           && cfun->can_throw_non_call_exceptions)
       && !ix86_frame_pointer_required ()
-      && get_frame_size () == 0
       && ix86_nsaved_sseregs () == 0
       && ix86_varargs_gpr_size + ix86_varargs_fpr_size == 0)
     {
index 4e0e910ebf1bb902c8938285757fe6fccbbdc9a6..fc5d5ad3da3e943e6dca90634e625632f81ffdbb 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/88483
+       * gcc.target/i386/stackalign/pr88483.c: New test.
+
 2018-12-14  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/max_size.adb: New test.
diff --git a/gcc/testsuite/gcc.target/i386/stackalign/pr88483.c b/gcc/testsuite/gcc.target/i386/stackalign/pr88483.c
new file mode 100644 (file)
index 0000000..5aec8fd
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -mavx2" } */
+
+struct B
+{
+  char a[12];
+  int b;
+};
+
+struct B
+f2 (void)
+{
+  struct B x = {};
+  return x;
+}
+
+/* { dg-final { scan-assembler-not "and\[lq\]?\[^\\n\]*-\[0-9\]+,\[^\\n\]*sp" } } */