[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 7c6fb7631c05444141a66c35383d6ee0e39123a7..43c1b3a3d55361ece43dcc3b3b0dcd0cf377007f 100644 (file)
@@ -1,3 +1,7 @@
+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,
index a0012c0ccf3e21f938c41472536a501b0949dfac..0c4e91758b5dcda4adc6296773b3b12dab3ab941 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))
        {