summaryrefslogtreecommitdiff
path: root/gcc/function.c
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2019-08-20 05:32:49 +0000
committerBernd Edlinger <edlinger@gcc.gnu.org>2019-08-20 05:32:49 +0000
commit1bcec8dfa3d11438ec654df7879ad76bd19e07c6 (patch)
tree2d069013d7f5071eb1bc59d0c51569206499b556 /gcc/function.c
parent876013aa4107cedcb47533e52be8e757a6ff6495 (diff)
re PR middle-end/89544 (Argument marshalling incorrectly assumes stack slots are naturally aligned.)
2019-08-20 Bernd Edlinger <bernd.edlinger@hotmail.de> PR middle-end/89544 * function.c (assign_parm_find_stack_rtl): Use larger alignment when possible. testsuite: 2019-08-20 Bernd Edlinger <bernd.edlinger@hotmail.de> PR middle-end/89544 * gcc.target/arm/unaligned-argument-1.c: New test. * gcc.target/arm/unaligned-argument-2.c: New test. From-SVN: r274691
Diffstat (limited to 'gcc/function.c')
-rw-r--r--gcc/function.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/function.c b/gcc/function.c
index e368f7c013e..f8019513928 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -2697,8 +2697,23 @@ assign_parm_find_stack_rtl (tree parm, struct assign_parm_data_one *data)
intentionally forcing upward padding. Otherwise we have to come
up with a guess at the alignment based on OFFSET_RTX. */
poly_int64 offset;
- if (data->locate.where_pad != PAD_DOWNWARD || data->entry_parm)
+ if (data->locate.where_pad == PAD_NONE || data->entry_parm)
align = boundary;
+ else if (data->locate.where_pad == PAD_UPWARD)
+ {
+ align = boundary;
+ /* If the argument offset is actually more aligned than the nominal
+ stack slot boundary, take advantage of that excess alignment.
+ Don't make any assumptions if STACK_POINTER_OFFSET is in use. */
+ if (poly_int_rtx_p (offset_rtx, &offset)
+ && STACK_POINTER_OFFSET == 0)
+ {
+ unsigned int offset_align = known_alignment (offset) * BITS_PER_UNIT;
+ if (offset_align == 0 || offset_align > STACK_BOUNDARY)
+ offset_align = STACK_BOUNDARY;
+ align = MAX (align, offset_align);
+ }
+ }
else if (poly_int_rtx_p (offset_rtx, &offset))
{
align = least_bit_hwi (boundary);