[2/4] lm32: Skip last named param when computing save varargs regs

Message ID 20250113202607.3288177-3-keithp@keithp.com
State Committed
Commit 6e593fcda49b1001e87e94ab709607b4fb2c66cf
Headers
Series lm32: varargs patches |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Test passed

Commit Message

Keith Packard Jan. 13, 2025, 8:08 p.m. UTC
  The cumulative args value in setup_incoming_varargs points at
the last named parameter. We need to skip over that (if present) to
get to the first anonymous argument as we only want to include
those anonymous args in the saved register block.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 gcc/config/lm32/lm32.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gcc/config/lm32/lm32.cc b/gcc/config/lm32/lm32.cc
index d78efc59da5..dfec28608a0 100644
--- a/gcc/config/lm32/lm32.cc
+++ b/gcc/config/lm32/lm32.cc
@@ -679,14 +679,18 @@  lm32_setup_incoming_varargs (cumulative_args_t cum_v,
 			     const function_arg_info &arg,
 			     int *pretend_size, int no_rtl)
 {
-  CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
+  CUMULATIVE_ARGS next_cum = *get_cumulative_args (cum_v);
   int first_anon_arg;
   tree fntype;
 
   fntype = TREE_TYPE (current_function_decl);
 
+  if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl))
+      || arg.type != NULL_TREE)
+    lm32_function_arg_advance (pack_cumulative_args (&next_cum), arg);
+
   if (stdarg_p (fntype))
-    first_anon_arg = *cum + LM32_FIRST_ARG_REG;
+    first_anon_arg = next_cum + LM32_FIRST_ARG_REG;
   else
     {
       /* this is the common case, we have been passed details setup
@@ -697,7 +701,7 @@  lm32_setup_incoming_varargs (cumulative_args_t cum_v,
       int size = arg.promoted_size_in_bytes ();
 
       first_anon_arg =
-	*cum + LM32_FIRST_ARG_REG +
+	next_cum + LM32_FIRST_ARG_REG +
 	((size + UNITS_PER_WORD - 1) / UNITS_PER_WORD);
     }