From: "Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "Joseph S. Myers" <joseph@codesourcery.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: Fix up TYPE_NO_NAMED_ARGS_STDARG_P handling [PR107453]
Date: Thu, 29 Feb 2024 14:10:45 +0000 [thread overview]
Message-ID: <23c7c873-1954-43b2-80b8-714455eaaf2b@arm.com> (raw)
In-Reply-To: <Zd4bAR8cXrhlzRiK@tucnak>
On 27/02/2024 17:25, Jakub Jelinek wrote:
> On Tue, Feb 27, 2024 at 04:41:32PM +0000, Richard Earnshaw wrote:
>>> 2023-01-09 Jakub Jelinek <jakub@redhat.com>
>>>
>>> PR target/107453
>>> * calls.cc (expand_call): For calls with
>>> TYPE_NO_NAMED_ARGS_STDARG_P (funtype) use zero for n_named_args.
>>> Formatting fix.
>>
>> This one has been festering for a while; both Alexandre and Torbjorn have attempted to fix it recently, but I'm not sure either is really right...
>>
>> On Arm this is causing all anonymous arguments to be passed on the stack,
>> which is incorrect per the ABI. On a target that uses
>> 'pretend_outgoing_vararg_named', why is it correct to set n_named_args to
>> zero? Is it enough to guard both the statements you've added with
>> !targetm.calls.pretend_outgoing_args_named?
>
> I'm afraid I haven't heard of that target hook before.
> All I was doing with that change was fixing a regression reported in the PR
> for ppc64le/sparc/nvptx/loongarch at least.
>
> The TYPE_NO_NAMED_ARGS_STDARG_P functions (C23 fns like void foo (...) {})
> have NULL type_arg_types, so the list_length (type_arg_types) isn't done for
> it, but it should be handled as if it was non-NULL but list length was 0.
>
> So, for the
> if (type_arg_types != 0)
> n_named_args
> = (list_length (type_arg_types)
> /* Count the struct value address, if it is passed as a parm. */
> + structure_value_addr_parm);
> else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype))
> n_named_args = 0;
> else
> /* If we know nothing, treat all args as named. */
> n_named_args = num_actuals;
> case, I think guarding it by any target hooks is wrong, although
> I guess it should have been
> n_named_args = structure_value_addr_parm;
> instead of
> n_named_args = 0;
>
> For the second
> if (type_arg_types != 0
> && targetm.calls.strict_argument_naming (args_so_far))
> ;
> else if (type_arg_types != 0
> && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far))
> /* Don't include the last named arg. */
> --n_named_args;
> else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype))
> n_named_args = 0;
> else
> /* Treat all args as named. */
> n_named_args = num_actuals;
> bet (but no testing done, don't even know which targets return what for
> those hooks) we should treat those as if type_arg_types was non-NULL
> with 0 elements in the list, except the --n_named_args doesn't make sense
> because that would decrease it to -1.
> So perhaps
> if ((type_arg_types != 0 || TYPE_NO_NAMED_ARGS_STDARG_P (funtype))
> && targetm.calls.strict_argument_naming (args_so_far))
> ;
> else if (type_arg_types != 0
> && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far))
> /* Don't include the last named arg. */
> --n_named_args;
> else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype)
> && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far)))
> ;
> else
> /* Treat all args as named. */
> n_named_args = num_actuals;
I tried the above on arm, aarch64 and x86_64 and that seems fine, including the new testcase you added.
R.
>
> (or n_named_args = 0; instead of ; before the final else? Dunno).
> I guess we need some testsuite coverage for caller/callee ABI match of
> struct S { char p[64]; };
> struct S foo (...);
>
> Jakub
>
next prev parent reply other threads:[~2024-02-29 14:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 10:32 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) [this message]
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
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=23c7c873-1954-43b2-80b8-714455eaaf2b@arm.com \
--to=richard.earnshaw@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=jeffreyalaw@gmail.com \
--cc=joseph@codesourcery.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).