My mistake yesterday.  I thought I'd tested both x86_64 -m64/-m32, but not so.
Anyway, as the comment says, the backend keeps querying the static chain, and
if you don't early out, it sets ix86_static_chain_on_stack, at which point the
setting is permanent and affects prologue generation, and not in a good way.

Tested i686-linux and committed.


r~
        PR target/63977
        * config/i386/i386.c (ix86_static_chain): Reinstate the check
        for DECL_STATIC_CHAIN.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index fffddfc..6c8dbd6 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -27360,6 +27360,12 @@ ix86_static_chain (const_tree fndecl_or_type, bool 
incoming_p)
 {
   unsigned regno;
 
+  /* While this function won't be called by the middle-end when a static
+     chain isn't needed, it's also used throughout the backend so it's
+     easiest to keep this check centralized.  */
+  if (DECL_P (fndecl_or_type) && !DECL_STATIC_CHAIN (fndecl_or_type))
+    return NULL;
+
   if (TARGET_64BIT)
     {
       /* We always use R10 in 64-bit mode.  */

Reply via email to