diff options
author | H.J. Lu <hongjiu.lu@intel.com> | 2017-07-09 18:25:49 +0000 |
---|---|---|
committer | H.J. Lu <hjl@gcc.gnu.org> | 2017-07-09 11:25:49 -0700 |
commit | 35c95658180e67503f9de96567ab4d6e71b10a6e (patch) | |
tree | 958a5f65c985b55904f9ac79c387b66910f49bfc /gcc/config | |
parent | 4669526d7eee93bc6c5b54b6accf98b384f36f56 (diff) | |
download | gcc-35c95658180e67503f9de96567ab4d6e71b10a6e.zip gcc-35c95658180e67503f9de96567ab4d6e71b10a6e.tar.gz gcc-35c95658180e67503f9de96567ab4d6e71b10a6e.tar.bz2 |
x86: Use DRAP only if there are outgoing arguments on stack
Since DRAP is needed only if there are outgoing arguments on stack, we
should track outgoing arguments on stack and avoid setting need_drap to
true when there are no outgoing arguments on stack.
gcc/
PR target/81313
* config/i386/i386.c (ix86_function_arg_advance): Set
outgoing_args_on_stack to true if there are outgoing arguments
on stack.
(ix86_function_arg): Likewise.
(ix86_get_drap_rtx): Use DRAP only if there are outgoing
arguments on stack and ACCUMULATE_OUTGOING_ARGS is false.
* config/i386/i386.h (machine_function): Add
outgoing_args_on_stack.
gcc/testsuite/
PR target/81313
* gcc.target/i386/pr81313-1.c: New test.
* gcc.target/i386/pr81313-2.c: Likewise.
* gcc.target/i386/pr81313-3.c: Likewise.
* gcc.target/i386/pr81313-4.c: Likewise.
* gcc.target/i386/pr81313-5.c: Likewise.
From-SVN: r250084
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/i386/i386.c | 18 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 3 |
2 files changed, 19 insertions, 2 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index afd61bf..42e0dda 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -10143,7 +10143,13 @@ ix86_function_arg_advance (cumulative_args_t cum_v, machine_mode mode, /* For pointers passed in memory we expect bounds passed in Bounds Table. */ if (!nregs) - cum->bnds_in_bt = chkp_type_bounds_count (type); + { + /* Track if there are outgoing arguments on stack. */ + if (cum->caller) + cfun->machine->outgoing_args_on_stack = true; + + cum->bnds_in_bt = chkp_type_bounds_count (type); + } } /* Define where to put the arguments to a function. @@ -10473,6 +10479,10 @@ ix86_function_arg (cumulative_args_t cum_v, machine_mode omode, else arg = function_arg_32 (cum, mode, omode, type, bytes, words); + /* Track if there are outgoing arguments on stack. */ + if (arg == NULL_RTX && cum->caller) + cfun->machine->outgoing_args_on_stack = true; + return arg; } @@ -13646,7 +13656,11 @@ ix86_update_stack_boundary (void) static rtx ix86_get_drap_rtx (void) { - if (ix86_force_drap || !ACCUMULATE_OUTGOING_ARGS) + /* We must use DRAP if there are outgoing arguments on stack and + ACCUMULATE_OUTGOING_ARGS is false. */ + if (ix86_force_drap + || (cfun->machine->outgoing_args_on_stack + && !ACCUMULATE_OUTGOING_ARGS)) crtl->need_drap = true; if (stack_realign_drap) diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 08243c1..a2ae9b4 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2657,6 +2657,9 @@ struct GTY(()) machine_function { frame pointer.) */ unsigned int call_ms2sysv_extra_regs:3; + /* Nonzero if the function places outgoing arguments on stack. */ + BOOL_BITFIELD outgoing_args_on_stack : 1; + /* During prologue/epilogue generation, the current frame state. Otherwise, the frame state at the end of the prologue. */ struct machine_frame_state fs; |