public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7894] arm: temporarily disable 'local' pcs selection (PR96882)
@ 2022-03-29 16:05 Richard Earnshaw
  0 siblings, 0 replies; only message in thread
From: Richard Earnshaw @ 2022-03-29 16:05 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1dca4ca1bf2f1b05537a1052e373d8b0ff11e53c

commit r12-7894-g1dca4ca1bf2f1b05537a1052e373d8b0ff11e53c
Author: Richard Earnshaw <rearnsha@arm.com>
Date:   Tue Mar 29 16:59:37 2022 +0100

    arm: temporarily disable 'local' pcs selection (PR96882)
    
    The arm port has an optimization used during selection of the
    function's ABI to permit deviation from the strict ABI when the
    function does not escape the current translation unit.
    
    Unfortunately, the ABI selection it makes can be unsafe if it changes
    how a result is returned because not enough information is available
    via the RETURN_IN_MEMORY hook to determine where the function gets
    used.  This can result in some parts of the compiler thinking a value
    is returned in memory while others think it is returned in registers.
    
    To mitigate this, this patch temporarily disables the optimization and
    falls back to using the default ABI for the translation.
    
    gcc/ChangeLog:
    
            PR target/96882
            * config/arm/arm.cc (arm_get_pcs_model): Disable selection of
            ARM_PCS_AAPCS_LOCAL.

Diff:
---
 gcc/config/arm/arm.cc | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index e062361b985..26ed7f97fc6 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -6194,7 +6194,7 @@ arm_pcs_from_attribute (tree attr)
    specification, DECL is the specific declartion.  DECL may be null if
    the call could be indirect or if this is a library call.  */
 static enum arm_pcs
-arm_get_pcs_model (const_tree type, const_tree decl)
+arm_get_pcs_model (const_tree type, const_tree decl ATTRIBUTE_UNUSED)
 {
   bool user_convention = false;
   enum arm_pcs user_pcs = arm_pcs_default;
@@ -6228,6 +6228,14 @@ arm_get_pcs_model (const_tree type, const_tree decl)
 	return ARM_PCS_AAPCS;
       else if (user_convention)
 	return user_pcs;
+#if 0
+      /* Unfortunately, this is not safe and can lead to wrong code
+	 being generated (PR96882).  Not all calls into the back-end
+	 pass the DECL, so it is unsafe to make any PCS-changing
+	 decisions based on it.  In particular the RETURN_IN_MEMORY
+	 hook is only ever passed a TYPE.  This needs revisiting to
+	 see if there are any partial improvements that can be
+	 re-enabled.  */
       else if (decl && flag_unit_at_a_time)
 	{
 	  /* Local functions never leak outside this compilation unit,
@@ -6239,6 +6247,7 @@ arm_get_pcs_model (const_tree type, const_tree decl)
 	  if (local_info_node && local_info_node->local)
 	    return ARM_PCS_AAPCS_LOCAL;
 	}
+#endif
     }
   else if (user_convention && user_pcs != arm_pcs_default)
     sorry ("PCS variant");


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-29 16:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 16:05 [gcc r12-7894] arm: temporarily disable 'local' pcs selection (PR96882) Richard Earnshaw

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