From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
Jeff Law <jeffreyalaw@gmail.com>,
gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] calls: Fix up TYPE_NO_NAMED_ARGS_STDARG_P handling [PR107453]
Date: Mon, 9 Jan 2023 11:58:50 +0000 (UTC) [thread overview]
Message-ID: <nycvar.YFH.7.77.849.2301091158440.14771@jbgna.fhfr.qr> (raw)
In-Reply-To: <Y7vtQYCoWik3D9Wc@tucnak>
On Mon, 9 Jan 2023, Jakub Jelinek wrote:
> Hi!
>
> On powerpc64le-linux, the following patch fixes
> -FAIL: gcc.dg/c2x-stdarg-4.c execution test
> -FAIL: gcc.dg/torture/c2x-stdarg-split-1a.c -O0 execution test
> -FAIL: gcc.dg/torture/c2x-stdarg-split-1a.c -O1 execution test
> -FAIL: gcc.dg/torture/c2x-stdarg-split-1a.c -O2 execution test
> -FAIL: gcc.dg/torture/c2x-stdarg-split-1a.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test
> -FAIL: gcc.dg/torture/c2x-stdarg-split-1a.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test
> -FAIL: gcc.dg/torture/c2x-stdarg-split-1a.c -O3 -g execution test
> -FAIL: gcc.dg/torture/c2x-stdarg-split-1a.c -Os execution test
> The problem is mismatch between the caller and callee side.
> On the callee side, we do:
> /* NAMED_ARG is a misnomer. We really mean 'non-variadic'. */
> if (!cfun->stdarg)
> data->arg.named = 1; /* No variadic parms. */
> else if (DECL_CHAIN (parm))
> data->arg.named = 1; /* Not the last non-variadic parm. */
> else if (targetm.calls.strict_argument_naming (all->args_so_far))
> data->arg.named = 1; /* Only variadic ones are unnamed. */
> else
> data->arg.named = 0; /* Treat as variadic. */
> which is later passed to the target hooks to determine if a particular
> argument is named or not. Now, cfun->stdarg is determined from the stdarg_p
> call, which for the new C2X TYPE_NO_NAMED_ARGS_STDARG_P function types
> (rettype fn (...)) returns true. Such functions have no named arguments,
> so data->arg.named will be 0 in function.cc. But on the caller side,
> as TYPE_NO_NAMED_ARGS_STDARG_P function types have TYPE_ARG_TYPES NULL,
> we instead treat those calls as unprototyped even when they are prototyped
> - /* If we know nothing, treat all args as named. */ n_named_args = num_actuals;
> in 2 spots. We need to treat the TYPE_NO_NAMED_ARGS_STDARG_P cases as
> prototyped with no named arguments.
>
> Bootstrapped/regtested on x86_64-linux, i686-linux, powerpc64le-linux (where
> it fixes the above failures), aarch64-linux and s390x-linux, ok for trunk?
LGTM.
Richard.
> 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.
>
> --- gcc/calls.cc.jj 2023-01-02 09:32:28.834192105 +0100
> +++ gcc/calls.cc 2023-01-06 14:52:14.740594896 +0100
> @@ -2908,8 +2908,8 @@ expand_call (tree exp, rtx target, int i
> }
>
> /* Count the arguments and set NUM_ACTUALS. */
> - num_actuals =
> - call_expr_nargs (exp) + num_complex_actuals + structure_value_addr_parm;
> + num_actuals
> + = call_expr_nargs (exp) + num_complex_actuals + structure_value_addr_parm;
>
> /* Compute number of named args.
> First, do a raw count of the args for INIT_CUMULATIVE_ARGS. */
> @@ -2919,6 +2919,8 @@ expand_call (tree exp, rtx target, int i
> = (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;
> @@ -2957,6 +2959,8 @@ expand_call (tree exp, rtx target, int i
> && ! 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;
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)
next prev parent reply other threads:[~2023-01-09 11:58 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 [this message]
2024-02-27 16:41 ` Richard Earnshaw
2024-02-27 17:25 ` 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
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-03-01 4:53 ` [PATCH] calls: Fix up " 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=nycvar.YFH.7.77.849.2301091158440.14771@jbgna.fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=jeffreyalaw@gmail.com \
--cc=joseph@codesourcery.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).