[NDS32] Fix wrong input value of parameter from stack for variable-length function.
authorChung-Ju Wu <jasonwucj@gmail.com>
Sun, 22 Apr 2018 08:25:47 +0000 (08:25 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Sun, 22 Apr 2018 08:25:47 +0000 (08:25 +0000)
gcc/
* config/nds32/nds32.c (nds32_compute_stack_frame): Fix wrong value.

From-SVN: r259549

gcc/ChangeLog
gcc/config/nds32/nds32.c

index 7c6fb76..43c1b3a 100644 (file)
@@ -1,5 +1,9 @@
 2018-04-22  Chung-Ju Wu  <jasonwucj@gmail.com>
 
+       * config/nds32/nds32.c (nds32_compute_stack_frame): Fix wrong value.
+
+2018-04-22  Chung-Ju Wu  <jasonwucj@gmail.com>
+
        * config/nds32/nds32-protos.h (nds32_data_alignment,
        nds32_local_alignment): Declare.
        * config/nds32/nds32.c (nds32_data_alignment, nds32_constant_alignment,
index a0012c0..0c4e917 100644 (file)
@@ -611,10 +611,12 @@ nds32_compute_stack_frame (void)
     {
       block_size = cfun->machine->fp_size
                   + cfun->machine->gp_size
-                  + cfun->machine->lp_size
-                  + (4 * (cfun->machine->callee_saved_last_gpr_regno
-                          - cfun->machine->callee_saved_first_gpr_regno
-                          + 1));
+                  + cfun->machine->lp_size;
+
+      if (cfun->machine->callee_saved_last_gpr_regno != SP_REGNUM)
+       block_size += (4 * (cfun->machine->callee_saved_last_gpr_regno
+                           - cfun->machine->callee_saved_first_gpr_regno
+                           + 1));
 
       if (!NDS32_DOUBLE_WORD_ALIGN_P (block_size))
        {