[gcc r13-8397] calls: Further fixes for TYPE_NO_NAMED_ARGS_STDARG_P handling [PR114136]
Jakub Jelinek
jakub@gcc.gnu.org
Sat Mar 2 00:39:31 GMT 2024
https://gcc.gnu.org/g:96e6576a1ba0080e70fef4a6f9cc3129fcf6f008
commit r13-8397-g96e6576a1ba0080e70fef4a6f9cc3129fcf6f008
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Mar 1 15:42:52 2024 +0100
calls: Further fixes for TYPE_NO_NAMED_ARGS_STDARG_P handling [PR114136]
On Tue, Feb 27, 2024 at 04:41:32PM +0000, Richard Earnshaw wrote:
> On Arm the PR107453 change 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?
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;
I think we should treat those as if type_arg_types was non-NULL
with 0 elements in the list, except the --n_named_args would for
!structure_value_addr_parm lead to n_named_args = -1, I think we want
0 for that case.
2024-03-01 Jakub Jelinek <jakub@redhat.com>
PR middle-end/114136
* calls.cc (expand_call): For TYPE_NO_NAMED_ARGS_STDARG_P set
n_named_args initially before INIT_CUMULATIVE_ARGS to
structure_value_addr_parm rather than 0, after it don't modify
it if strict_argument_naming and clear only if
!pretend_outgoing_varargs_named.
(cherry picked from commit b5377928a2a5cd2a79eda59e2eba7d0511bf7566)
Diff:
---
gcc/calls.cc | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gcc/calls.cc b/gcc/calls.cc
index 4d7f6c3d291..53b0f58b709 100644
--- a/gcc/calls.cc
+++ b/gcc/calls.cc
@@ -2920,7 +2920,7 @@ expand_call (tree exp, rtx target, int ignore)
/* 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;
+ n_named_args = structure_value_addr_parm;
else
/* If we know nothing, treat all args as named. */
n_named_args = num_actuals;
@@ -2952,14 +2952,15 @@ expand_call (tree exp, rtx target, int ignore)
we do not have any reliable way to pass unnamed args in
registers, so we must force them into memory. */
- if (type_arg_types != 0
+ 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))
+ else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype)
+ && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far))
n_named_args = 0;
else
/* Treat all args as named. */
More information about the Gcc-cvs
mailing list