]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/config/i386/i386-options.c
x86: Don't allocate stack frame nor align stack if not needed
authorH.J. Lu <hongjiu.lu@intel.com>
Wed, 22 May 2019 18:53:37 +0000 (18:53 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Wed, 22 May 2019 18:53:37 +0000 (11:53 -0700)
commitc2080a1fb549a99d567ff6834e06163fb883bf54
treed22718b9405e0484f17f6470ef6f978b020b76bc
parent586e53e269d04c2806f0f6bb6a1aa5db81efc0d4
x86: Don't allocate stack frame nor align stack if not needed

get_frame_size () returns used stack slots during compilation, which
may be optimized out later.  This patch does the followings:

1. Add stack_frame_required to machine_function to indicate that the
function needs a stack frame.
2. Change ix86_find_max_used_stack_alignment to set stack_frame_required.
3. Always call ix86_find_max_used_stack_alignment to check if stack
frame is needed.

Tested on i686 and x86-64 with

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

Tested on AVX512 machine configured with

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

gcc/

PR target/88483
* config/i386/i386-options.c (ix86_init_machine_status): Set
stack_frame_required to true.
* config/i386/i386.c (ix86_get_frame_size): New function.
(ix86_frame_pointer_required): Replace get_frame_size with
ix86_get_frame_size.
(ix86_compute_frame_layout): Likewise.
(ix86_find_max_used_stack_alignment): Changed to void.  Set
stack_frame_required.
(ix86_finalize_stack_frame_flags): Always call
ix86_find_max_used_stack_alignment.  Replace get_frame_size with
ix86_get_frame_size.
* config/i386/i386.h (machine_function): Add stack_frame_required.

gcc/testsuite/

PR target/88483
* gcc.target/i386/stackalign/pr88483-1.c: New test.
* gcc.target/i386/stackalign/pr88483-2.c: Likewise.

From-SVN: r271517
gcc/ChangeLog
gcc/config/i386/i386-options.c
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/stackalign/pr88483-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/stackalign/pr88483-2.c [new file with mode: 0644]