This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]