diff options
author | H.J. Lu <hongjiu.lu@intel.com> | 2019-06-14 16:24:56 +0000 |
---|---|---|
committer | H.J. Lu <hjl@gcc.gnu.org> | 2019-06-14 09:24:56 -0700 |
commit | 957ed7386177e7d5da6b2908ec576906b784c892 (patch) | |
tree | 35f27a49da3ff03bcfef1dce5de62f8d966ed6d5 /gcc/calls.c | |
parent | 84d38abbc982db405cfe7a45ed53c64745da5511 (diff) | |
download | gcc-957ed7386177e7d5da6b2908ec576906b784c892.zip gcc-957ed7386177e7d5da6b2908ec576906b784c892.tar.gz gcc-957ed7386177e7d5da6b2908ec576906b784c892.tar.bz2 |
Update preferred_stack_boundary only when expanding function call
locate_and_pad_parm is called when expanding function call from
initialize_argument_information and when generating function body
from assign_parm_find_entry_rtl:
/* Remember if the outgoing parameter requires extra alignment on the
calling function side. */
if (crtl->stack_alignment_needed < boundary)
crtl->stack_alignment_needed = boundary;
if (crtl->preferred_stack_boundary < boundary)
crtl->preferred_stack_boundary = boundary;
stack_alignment_needed and preferred_stack_boundary should be updated
only when expanding function call, not when generating function body.
Add update_stack_alignment_for_call to update stack alignment when
outgoing parameter is passed in the stack.
gcc/
PR rtl-optimization/90765
* calls.c (update_stack_alignment_for_call): New function.
(expand_call): Call update_stack_alignment_for_call when
outgoing parameter is passed in the stack.
(emit_library_call_value_1): Likewise.
* function.c (locate_and_pad_parm): Don't update
stack_alignment_needed and preferred_stack_boundary.
gcc/testsuite/
PR rtl-optimization/90765
* gcc.target/i386/pr90765-1.c: New test.
* gcc.target/i386/pr90765-2.c: Likewise.
From-SVN: r272296
Diffstat (limited to 'gcc/calls.c')
-rw-r--r-- | gcc/calls.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/calls.c b/gcc/calls.c index c8a4268..6ab138e 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -3226,6 +3226,19 @@ can_implement_as_sibling_call_p (tree exp, return true; } +/* Update stack alignment when the parameter is passed in the stack + since the outgoing parameter requires extra alignment on the calling + function side. */ + +static void +update_stack_alignment_for_call (struct locate_and_pad_arg_data *locate) +{ + if (crtl->stack_alignment_needed < locate->boundary) + crtl->stack_alignment_needed = locate->boundary; + if (crtl->preferred_stack_boundary < locate->boundary) + crtl->preferred_stack_boundary = locate->boundary; +} + /* Generate all the code for a CALL_EXPR exp and return an rtx for its value. Store the value in TARGET (specified as an rtx) if convenient. @@ -3703,6 +3716,12 @@ expand_call (tree exp, rtx target, int ignore) /* Ensure current function's preferred stack boundary is at least what we need. Stack alignment may also increase preferred stack boundary. */ + for (i = 0; i < num_actuals; i++) + if (reg_parm_stack_space > 0 + || args[i].reg == 0 + || args[i].partial != 0 + || args[i].pass_on_stack) + update_stack_alignment_for_call (&args[i].locate); if (crtl->preferred_stack_boundary < preferred_stack_boundary) crtl->preferred_stack_boundary = preferred_stack_boundary; else @@ -4961,6 +4980,12 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, targetm.calls.function_arg_advance (args_so_far, mode, (tree) 0, true); } + for (int i = 0; i < nargs; i++) + if (reg_parm_stack_space > 0 + || argvec[i].reg == 0 + || argvec[i].partial != 0) + update_stack_alignment_for_call (&argvec[i].locate); + /* If this machine requires an external definition for library functions, write one out. */ assemble_external_libcall (fun); |