[v2] RISC-V: Make sure stack is always aligned during adjusting

Message ID CA+yXCZD705Q0Ni6C6YdcXg_qDbKY8fvL6AXRuFQz59mhm_zRGg@mail.gmail.com
State New
Headers show
Series
  • [v2] RISC-V: Make sure stack is always aligned during adjusting
Related show

Commit Message

Kito Cheng April 20, 2018, 2:48 a.m.
It's v2 patch for fixing stack align for rv32*c target.

gcc/ChangeLog:

2018-04-18  Kito Cheng  <kito.cheng@gmail.com>

         * config/riscv/riscv.c (riscv_first_stack_step): Round up min
         step to make sure stack always aligned.

v1: https://gcc.gnu.org/ml/gcc-patches/2018-04/msg00877.html

Comments

Jim Wilson April 20, 2018, 7:06 p.m. | #1
On Thu, Apr 19, 2018 at 7:48 PM, Kito Cheng <kito.cheng@gmail.com> wrote:
> 2018-04-18  Kito Cheng  <kito.cheng@gmail.com>

>

>          * config/riscv/riscv.c (riscv_first_stack_step): Round up min

>          step to make sure stack always aligned.


Committed.

Jim

Patch

From 3787f36a689222dd3b0b95e9f2c54b7fbaa8c671 Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng@gmail.com>
Date: Wed, 18 Apr 2018 17:51:35 +0800
Subject: [PATCH] RISC-V: Make sure stack is always aligned during adjusting
 stack.

gcc/ChangeLog:

2018-04-18  Kito Cheng  <kito.cheng@gmail.com>

	* config/riscv/riscv.c (riscv_first_stack_step): Round up min
	step to make sure stack always aligned.
---
 gcc/config/riscv/riscv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c
index 2870177fa97..2a8f87d1e94 100644
--- a/gcc/config/riscv/riscv.c
+++ b/gcc/config/riscv/riscv.c
@@ -3507,7 +3507,8 @@  riscv_first_stack_step (struct riscv_frame_info *frame)
   if (SMALL_OPERAND (frame->total_size))
     return frame->total_size;
 
-  HOST_WIDE_INT min_first_step = frame->total_size - frame->fp_sp_offset;
+  HOST_WIDE_INT min_first_step =
+    RISCV_STACK_ALIGN (frame->total_size - frame->fp_sp_offset);
   HOST_WIDE_INT max_first_step = IMM_REACH / 2 - PREFERRED_STACK_BOUNDARY / 8;
   HOST_WIDE_INT min_second_step = frame->total_size - max_first_step;
   gcc_assert (min_first_step <= max_first_step);
-- 
2.11.2