aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Wilson <jimw@sifive.com>2018-04-17 21:41:07 +0000
committerJim Wilson <wilson@gcc.gnu.org>2018-04-17 14:41:07 -0700
commit035fc2add18c0dd06c22bd158a47bf35b8c1c528 (patch)
treed7a3fd5c0cd7a1e37a3b3ea228d5bd4cbad7857a
parentcbe679a486d11b1d959042732a9ddc204afbb661 (diff)
downloadgcc-035fc2add18c0dd06c22bd158a47bf35b8c1c528.zip
gcc-035fc2add18c0dd06c22bd158a47bf35b8c1c528.tar.gz
gcc-035fc2add18c0dd06c22bd158a47bf35b8c1c528.tar.bz2
RISC-V: Fix 32-bit stack pointer alignment problem.
gcc/ PR 84856 * config/riscv/riscv.c (riscv_compute_frame_info): Add calls to RISCV_STACK_ALIGN when using outgoing_args_size and pretend_args_size. Set arg_pointer_offset after using pretend_args_size. From-SVN: r259449
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/riscv/riscv.c8
2 files changed, 12 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1fba2d9..bf4f7cc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-04-17 Jim Wilson <jimw@sifive.com>
+
+ PR 84856
+ * config/riscv/riscv.c (riscv_compute_frame_info): Add calls to
+ RISCV_STACK_ALIGN when using outgoing_args_size and pretend_args_size.
+ Set arg_pointer_offset after using pretend_args_size.
+
2018-04-17 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/85431
diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c
index 9e1005e..2870177 100644
--- a/gcc/config/riscv/riscv.c
+++ b/gcc/config/riscv/riscv.c
@@ -3307,7 +3307,7 @@ riscv_compute_frame_info (void)
}
/* At the bottom of the frame are any outgoing stack arguments. */
- offset = crtl->outgoing_args_size;
+ offset = RISCV_STACK_ALIGN (crtl->outgoing_args_size);
/* Next are local stack variables. */
offset += RISCV_STACK_ALIGN (get_frame_size ());
/* The virtual frame pointer points above the local variables. */
@@ -3333,9 +3333,11 @@ riscv_compute_frame_info (void)
frame->hard_frame_pointer_offset = offset;
/* Above the hard frame pointer is the callee-allocated varags save area. */
offset += RISCV_STACK_ALIGN (cfun->machine->varargs_size);
- frame->arg_pointer_offset = offset;
/* Next is the callee-allocated area for pretend stack arguments. */
- offset += crtl->args.pretend_args_size;
+ offset += RISCV_STACK_ALIGN (crtl->args.pretend_args_size);
+ /* Arg pointer must be below pretend args, but must be above alignment
+ padding. */
+ frame->arg_pointer_offset = offset - crtl->args.pretend_args_size;
frame->total_size = offset;
/* Next points the incoming stack pointer and any incoming arguments. */