public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com>
Cc: "Joseph S. Myers" <josmyers@redhat.com>,
	"Richard Biener" <rguenther@suse.de>,
	"Jeff Law" <jeffreyalaw@gmail.com>,
	gcc-patches@gcc.gnu.org,
	"Torbjörn SVENSSON" <torbjorn.svensson@foss.st.com>,
	oliva@adacore.com
Subject: Re: [PATCH] calls: Further fixes for TYPE_NO_NAMED_ARGS_STDARG_P handling [PR107453]
Date: Thu, 29 Feb 2024 18:38:36 +0100	[thread overview]
Message-ID: <ZeDBHAOXrResFfcF@tucnak> (raw)
In-Reply-To: <9b4f43f8-3807-432f-b1a2-e0515ab198ca@arm.com>

On Thu, Feb 29, 2024 at 05:23:25PM +0000, Richard Earnshaw (lists) wrote:
> On 29/02/2024 15:55, Jakub Jelinek wrote:
> > On Thu, Feb 29, 2024 at 02:14:05PM +0000, Richard Earnshaw wrote:
> >>> I tried the above on arm, aarch64 and x86_64 and that seems fine,
> >>> including the new testcase you added.
> >>>
> >>
> >> I should mention though, that INIT_CUMULATIVE_ARGS on arm ignores
> >> n_named_args entirely, it doesn't need it (I don't think it even existed
> >> when the AAPCS code was added).
> > 
> > So far I've just checked that the new testcase passes not just on
> > x86_64/i686-linux, but also on {powerpc64le,s390x,aarch64}-linux
> > with vanilla trunk.
> > Haven't posted this patch in patch form, plus while I'm not really sure
> > whether setting n_named_args to 0 or not changing in the
> > !pretend_outgoing_varargs_named is right, the setting to 0 feels more
> > correct to me.  If structure_value_addr_parm is 1, the function effectively
> > has a single named argument and then ... args and if the target wants
> > n_named_args to be number of named arguments except the last, then that
> > should be 0 rather than 1.
> > 
> > Thus, is the following patch ok for trunk then?
> 
> The comment at the start of the section says
> 
>   /* Now possibly adjust the number of named args.
>      Normally, don't include the last named arg if anonymous args follow.
>      We do include the last named arg if
>      targetm.calls.strict_argument_naming() returns nonzero.
>      (If no anonymous args follow, the result of list_length is actually
>      one too large.  This is harmless.)
> 
> So in the case of strict_argument_naming perhaps it should return 1, but 0 for other cases.

The TYPE_NO_NAMED_ARGS_STDARG_P (funtype) case is as if type_arg_types != 0
and list_length (type_arg_types) == 0, i.e. no user named arguments.
As list_length (NULL) returns 0, perhaps it could be even handled just the
by changing all the type_arg_types != 0 checks to
type_arg_types != 0 || TYPE_NO_NAMED_ARGS_STDARG_P (funtype)
There are just 2 cases I'm worried about, one is that I think rest of
calls.cc nor the backends are prepared to see n_named_args -1 after the
adjustments, I think it is better to use 0, and then the question is what
the !strict_argument_naming && !pretend_outgoing_varargs_named case
wants to do for the aggregate return.  The patch as posted for
void foo (...); void bar () { foo (1, 2, 3); }
will set n_named_args initially to 0 (no named args) and with the
adjustments for strict_argument_naming 0, otherwise for !pretend
0 as well, otherwise 3.
For
struct { char buf[4096]; } baz (...); void qux () { baz (1, 2, 3); }
the patch sets n_named_args initially to 1 (the hidden return) and
with the arguments for strict keep it at 1, for !pretend 0 and otherwise
3.

So, which case do you think is handled incorrectly with that?

	Jakub


  reply	other threads:[~2024-02-29 17:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 10:32 [PATCH] calls: Fix up " Jakub Jelinek
2023-01-09 11:58 ` Richard Biener
2024-02-27 16:41 ` Richard Earnshaw
2024-02-27 17:25   ` Jakub Jelinek
2024-02-27 17:54     ` Jakub Jelinek
2024-02-28  8:31       ` Jakub Jelinek
2024-02-29 14:10     ` Richard Earnshaw (lists)
2024-02-29 14:14       ` Richard Earnshaw
2024-02-29 15:55         ` [PATCH] calls: Further fixes for " Jakub Jelinek
2024-02-29 17:23           ` Richard Earnshaw (lists)
2024-02-29 17:38             ` Jakub Jelinek [this message]
2024-02-29 17:51               ` Richard Earnshaw (lists)
2024-02-29 17:56                 ` Jakub Jelinek
2024-03-01 13:53                   ` Richard Earnshaw (lists)
2024-03-01 14:00                     ` Jakub Jelinek
2024-03-01 14:16           ` Richard Earnshaw (lists)
2024-02-27 17:25   ` [PATCH] calls: Fix up " Richard Earnshaw
2024-03-01  4:53   ` Alexandre Oliva
2024-03-01  7:53     ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZeDBHAOXrResFfcF@tucnak \
    --to=jakub@redhat.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=josmyers@redhat.com \
    --cc=oliva@adacore.com \
    --cc=rguenther@suse.de \
    --cc=torbjorn.svensson@foss.st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).