public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] mips: Fix C23 (...) functions returning large aggregates [PR114175]
@ 2024-03-20  7:10 Xi Ruoyao
  2024-03-29  1:01 ` Ping: " Xi Ruoyao
  2024-03-29  5:20 ` YunQiang Su
  0 siblings, 2 replies; 3+ messages in thread
From: Xi Ruoyao @ 2024-03-20  7:10 UTC (permalink / raw)
  To: gcc-patches; +Cc: YunQiang Su, Jeff Law, Xi Ruoyao

We were assuming TYPE_NO_NAMED_ARGS_STDARG_P don't have any named
arguments and there is nothing to advance, but that is not the case
for (...) functions returning by hidden reference which have one such
artificial argument.  This is causing gcc.dg/c23-stdarg-{6,8,9}.c to
fail.

Fix the issue by checking if arg.type is NULL, as r14-9503 explains.

gcc/ChangeLog:

	PR target/114175
	* config/mips/mips.cc (mips_setup_incoming_varargs): Only skip
	mips_function_arg_advance for TYPE_NO_NAMED_ARGS_STDARG_P
	functions if arg.type is NULL.
---

Bootstrapped and regtested on mips64el-linux-gnuabi64.  Ok for trunk?

 gcc/config/mips/mips.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
index 68e2ae8d8fa..ce764a5cb35 100644
--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -6834,7 +6834,13 @@ mips_setup_incoming_varargs (cumulative_args_t cum,
      argument.  Advance a local copy of CUM past the last "real" named
      argument, to find out how many registers are left over.  */
   local_cum = *get_cumulative_args (cum);
-  if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl)))
+
+  /* For a C23 variadic function w/o any named argument, and w/o an
+     artifical argument for large return value, skip advancing args.
+     There is such an artifical argument iff. arg.type is non-NULL
+     (PR 114175).  */
+  if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl))
+      || arg.type != NULL_TREE)
     mips_function_arg_advance (pack_cumulative_args (&local_cum), arg);
 
   /* Found out how many registers we need to save.  */
-- 
2.44.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Ping: [PATCH] mips: Fix C23 (...) functions returning large aggregates [PR114175]
  2024-03-20  7:10 [PATCH] mips: Fix C23 (...) functions returning large aggregates [PR114175] Xi Ruoyao
@ 2024-03-29  1:01 ` Xi Ruoyao
  2024-03-29  5:20 ` YunQiang Su
  1 sibling, 0 replies; 3+ messages in thread
From: Xi Ruoyao @ 2024-03-29  1:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: YunQiang Su, Jeff Law

Ping.

On Wed, 2024-03-20 at 15:10 +0800, Xi Ruoyao wrote:
> We were assuming TYPE_NO_NAMED_ARGS_STDARG_P don't have any named
> arguments and there is nothing to advance, but that is not the case
> for (...) functions returning by hidden reference which have one such
> artificial argument.  This is causing gcc.dg/c23-stdarg-{6,8,9}.c to
> fail.
> 
> Fix the issue by checking if arg.type is NULL, as r14-9503 explains.
> 
> gcc/ChangeLog:
> 
> 	PR target/114175
> 	* config/mips/mips.cc (mips_setup_incoming_varargs): Only skip
> 	mips_function_arg_advance for TYPE_NO_NAMED_ARGS_STDARG_P
> 	functions if arg.type is NULL.
> ---
> 
> Bootstrapped and regtested on mips64el-linux-gnuabi64.  Ok for trunk?
> 
>  gcc/config/mips/mips.cc | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
> index 68e2ae8d8fa..ce764a5cb35 100644
> --- a/gcc/config/mips/mips.cc
> +++ b/gcc/config/mips/mips.cc
> @@ -6834,7 +6834,13 @@ mips_setup_incoming_varargs (cumulative_args_t cum,
>       argument.  Advance a local copy of CUM past the last "real" named
>       argument, to find out how many registers are left over.  */
>    local_cum = *get_cumulative_args (cum);
> -  if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl)))
> +
> +  /* For a C23 variadic function w/o any named argument, and w/o an
> +     artifical argument for large return value, skip advancing args.
> +     There is such an artifical argument iff. arg.type is non-NULL
> +     (PR 114175).  */
> +  if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl))
> +      || arg.type != NULL_TREE)
>      mips_function_arg_advance (pack_cumulative_args (&local_cum), arg);
>  
>    /* Found out how many registers we need to save.  */

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mips: Fix C23 (...) functions returning large aggregates [PR114175]
  2024-03-20  7:10 [PATCH] mips: Fix C23 (...) functions returning large aggregates [PR114175] Xi Ruoyao
  2024-03-29  1:01 ` Ping: " Xi Ruoyao
@ 2024-03-29  5:20 ` YunQiang Su
  1 sibling, 0 replies; 3+ messages in thread
From: YunQiang Su @ 2024-03-29  5:20 UTC (permalink / raw)
  To: Xi Ruoyao; +Cc: gcc-patches, Jeff Law

Xi Ruoyao <xry111@xry111.site> 于2024年3月20日周三 15:12写道:
>
> We were assuming TYPE_NO_NAMED_ARGS_STDARG_P don't have any named
> arguments and there is nothing to advance, but that is not the case
> for (...) functions returning by hidden reference which have one such
> artificial argument.  This is causing gcc.dg/c23-stdarg-{6,8,9}.c to
> fail.
>
> Fix the issue by checking if arg.type is NULL, as r14-9503 explains.
>
> gcc/ChangeLog:
>
>         PR target/114175
>         * config/mips/mips.cc (mips_setup_incoming_varargs): Only skip
>         mips_function_arg_advance for TYPE_NO_NAMED_ARGS_STDARG_P
>         functions if arg.type is NULL.
> ---
>
> Bootstrapped and regtested on mips64el-linux-gnuabi64.  Ok for trunk?
>

Thanks. LGTM.

>  gcc/config/mips/mips.cc | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
> index 68e2ae8d8fa..ce764a5cb35 100644
> --- a/gcc/config/mips/mips.cc
> +++ b/gcc/config/mips/mips.cc
> @@ -6834,7 +6834,13 @@ mips_setup_incoming_varargs (cumulative_args_t cum,
>       argument.  Advance a local copy of CUM past the last "real" named
>       argument, to find out how many registers are left over.  */
>    local_cum = *get_cumulative_args (cum);
> -  if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl)))
> +
> +  /* For a C23 variadic function w/o any named argument, and w/o an
> +     artifical argument for large return value, skip advancing args.
> +     There is such an artifical argument iff. arg.type is non-NULL
> +     (PR 114175).  */
> +  if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl))
> +      || arg.type != NULL_TREE)
>      mips_function_arg_advance (pack_cumulative_args (&local_cum), arg);
>
>    /* Found out how many registers we need to save.  */
> --
> 2.44.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-29  5:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-20  7:10 [PATCH] mips: Fix C23 (...) functions returning large aggregates [PR114175] Xi Ruoyao
2024-03-29  1:01 ` Ping: " Xi Ruoyao
2024-03-29  5:20 ` YunQiang Su

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).