public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-11-18  5:36 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-11-18  5:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5103cd70ff6cb71651e28fe51486d6c3f1591d79

commit 5103cd70ff6cb71651e28fe51486d6c3f1591d79
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 4 +++-
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 25a1ad736ad..c31bf193365 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7011,7 +7011,7 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
 
   /* Special case: if named is false then we are handling an incoming
      anonymous argument which is on the stack.  */
-  if (!named)
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7132,6 +7132,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-14 16:26 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-14 16:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8750df1495ce94dbb1e3eb216969cca6ed715636

commit 8750df1495ce94dbb1e3eb216969cca6ed715636
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Dec 14 03:21:24 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 0c0cb14a8a4..625bc8646c6 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7018,8 +7018,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7140,6 +7143,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-14 13:45 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-14 13:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5127d0dfa851bbce361b9b07f98965037b42c5b3

commit 5127d0dfa851bbce361b9b07f98965037b42c5b3
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Dec 14 03:21:24 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 0c0cb14a8a4..625bc8646c6 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7018,8 +7018,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7140,6 +7143,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-14 12:48 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-14 12:48 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:679884340245e10773e8bf94ef1c7b7155eff3a8

commit 679884340245e10773e8bf94ef1c7b7155eff3a8
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Dec 14 03:21:24 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 0c0cb14a8a4..625bc8646c6 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7018,8 +7018,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7140,6 +7143,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-12 20:23 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-12 20:23 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f1f79c5e822c884d7211d3a3b00f9ae43d0e8722

commit f1f79c5e822c884d7211d3a3b00f9ae43d0e8722
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Dec 12 00:09:02 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 6e3e2e8fb1b..4a350bd8c8f 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7019,8 +7019,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7141,6 +7144,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-12  2:38 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-12  2:38 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:dda970bae5f7d9faff4c8e60ba682b41de2ff361

commit dda970bae5f7d9faff4c8e60ba682b41de2ff361
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Dec 7 00:38:31 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 6e3e2e8fb1b..4a350bd8c8f 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7019,8 +7019,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7141,6 +7144,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-06 22:47 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-06 22:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5595f153ded5cd96ee7f9b6ce2e81cd701f44f86

commit 5595f153ded5cd96ee7f9b6ce2e81cd701f44f86
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 6e3e2e8fb1b..4a350bd8c8f 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7019,8 +7019,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7141,6 +7144,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-06 20:01 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-06 20:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:67e1b96a4a6a283ccbe100ac94da9d2485caff32

commit 67e1b96a4a6a283ccbe100ac94da9d2485caff32
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 6e3e2e8fb1b..4a350bd8c8f 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7019,8 +7019,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7141,6 +7144,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-06  2:31 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-06  2:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:458c1608feeb5f9e6dd980c06275e8801a44ceaa

commit 458c1608feeb5f9e6dd980c06275e8801a44ceaa
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 6e3e2e8fb1b..4a350bd8c8f 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7019,8 +7019,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7141,6 +7144,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-05 21:51 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-05 21:51 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d886c2334f38cbb80da54fc0fa7a78510585896b

commit d886c2334f38cbb80da54fc0fa7a78510585896b
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 6e3e2e8fb1b..4a350bd8c8f 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7019,8 +7019,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7141,6 +7144,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-05 19:30 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-05 19:30 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ace14485a1098b4b150fffe08ecd973831a5a675

commit ace14485a1098b4b150fffe08ecd973831a5a675
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 6e3e2e8fb1b..4a350bd8c8f 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7019,8 +7019,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7141,6 +7144,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-03  1:46 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-03  1:46 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:879e0651efaa6c3d53088caa24076b6866dc1084

commit 879e0651efaa6c3d53088caa24076b6866dc1084
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 25a1ad736ad..28cd199f095 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7010,8 +7010,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7132,6 +7135,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-12-02 17:48 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-12-02 17:48 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:78b705cdde6f0b68f6def8680ac0eab4ea929998

commit 78b705cdde6f0b68f6def8680ac0eab4ea929998
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 9 +++++++--
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 5cb35e8d061..9a49d1df4d9 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7019,8 +7019,11 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
   pcum->aapcs_arg_processed = true;
 
   /* Special case: if named is false then we are handling an incoming
-     anonymous argument which is on the stack.  */
-  if (!named)
+     anonymous argument which is on the stack, unless
+     aapcs_pretend_named, in which case we're dealing with a
+     TYPE_NO_NAMED_ARGS_STDARG_P call and, even if args are !named, we
+     ought to use available registers first.  */
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7141,6 +7144,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-11-23 11:46 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-11-23 11:46 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ffb04a06cb80769180a3402bb041ea0d818e6bd3

commit ffb04a06cb80769180a3402bb041ea0d818e6bd3
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 4 +++-
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 25a1ad736ad..c31bf193365 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7011,7 +7011,7 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
 
   /* Special case: if named is false then we are handling an incoming
      anonymous argument which is on the stack.  */
-  if (!named)
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7132,6 +7132,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

* [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg
@ 2023-11-19  4:44 Alexandre Oliva
  0 siblings, 0 replies; 15+ messages in thread
From: Alexandre Oliva @ 2023-11-19  4:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2b3cc86b3a72ce80c3c646cc1b72dabb3afad3a8

commit 2b3cc86b3a72ce80c3c646cc1b72dabb3afad3a8
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Sat Nov 18 02:11:49 2023 -0300

    arm: fix c23 0-named-args caller-side stdarg
    
    On arm-eabi targets, c23 stdarg execution tests that pass arguments to
    (...) functions (without any named argument), the caller passes
    everything on the stack, but the callee expects arguments in
    registers.  My reading of the AAPCS32 suggests that the caller is
    correct, so I've arranged for the caller to pass the first arguments
    in registers to TYPE_NO_NAMED_STDARG_P-typed functions.
    
    The implementation issue in calls.cc is that n_named_args is initially
    set to zero in expand_call, so the test argpos < n_named_args yields
    false for all arguments, and aapcs_layout_arg takes !named as meaning
    stack.
    
    But there's a catch there: on targets in which neither
    strict_argument_naming nor !pretend_outgoing_varargs_named hold,
    n_named_args is bumped up to num_actuals, which covers stdarg
    arguments in pre-c23 cases, but not for TYPE_NO_NAMED_ARGS_STDARG_P.
    
    I'm hesitant to modify the generic ABI-affecting code, so I'm going
    for a more surgical fix for ARM AAPCS only.  I suspect we might want
    yet another targetm predicate to enable the n_named_args overriding
    block to disregard TYPE_NO_NAMED_ARGS_STDARG_P, and allow all actuals
    to be passed as if named.
    
    
    for  gcc/ChangeLog
    
            * config/arm/arm.h (CUMULATIVE_ARGS): Add aapcs_pretend_named.
            * config/arm/arm.cc (arm_init_cumulative_args): Set it for
            aapcs no-named-args stdarg functions.
            (aapcs_layout_arg): Ignore named if aapcs_pretend_named.

Diff:
---
 gcc/config/arm/arm.cc | 4 +++-
 gcc/config/arm/arm.h  | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 25a1ad736ad..c31bf193365 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -7011,7 +7011,7 @@ aapcs_layout_arg (CUMULATIVE_ARGS *pcum, machine_mode mode,
 
   /* Special case: if named is false then we are handling an incoming
      anonymous argument which is on the stack.  */
-  if (!named)
+  if (!named && !pcum->aapcs_pretend_named)
     return;
 
   /* Is this a potential co-processor register candidate?  */
@@ -7132,6 +7132,8 @@ arm_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
       pcum->aapcs_arg_processed = false;
       pcum->aapcs_cprc_slot = -1;
       pcum->can_split = true;
+      pcum->aapcs_pretend_named = (fntype
+				   && TYPE_NO_NAMED_ARGS_STDARG_P (fntype));
 
       if (pcum->pcs_variant != ARM_PCS_AAPCS)
 	{
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index a9c2752c0ea..65d2d567686 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1702,6 +1702,7 @@ typedef struct
   unsigned aapcs_vfp_reg_alloc;
   int aapcs_vfp_rcount;
   MACHMODE aapcs_vfp_rmode;
+  bool aapcs_pretend_named; /* Set for TYPE_NO_NAMED_ARGS_STDARG_P.  */
 } CUMULATIVE_ARGS;
 #endif

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

end of thread, other threads:[~2023-12-14 16:26 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-18  5:36 [gcc(refs/users/aoliva/heads/testme)] arm: fix c23 0-named-args caller-side stdarg Alexandre Oliva
2023-11-19  4:44 Alexandre Oliva
2023-11-23 11:46 Alexandre Oliva
2023-12-02 17:48 Alexandre Oliva
2023-12-03  1:46 Alexandre Oliva
2023-12-05 19:30 Alexandre Oliva
2023-12-05 21:51 Alexandre Oliva
2023-12-06  2:31 Alexandre Oliva
2023-12-06 20:01 Alexandre Oliva
2023-12-06 22:47 Alexandre Oliva
2023-12-12  2:38 Alexandre Oliva
2023-12-12 20:23 Alexandre Oliva
2023-12-14 12:48 Alexandre Oliva
2023-12-14 13:45 Alexandre Oliva
2023-12-14 16:26 Alexandre Oliva

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).