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

commit c5a72cc80939e42518f4021e0640d29c8b8495a7
Author: Michael Matz <m...@suse.de>
Date:   Tue Jul 9 04:27:46 2024 +0200

    x86-ssw: fix testcases
    
    the separate-shrink-wrap infrastructure sometimes
    considers components as handled when they aren't in fact
    handled (e.g. never calling any emit_prologue_components or
    emit_epilogue_components hooks for the component in question).
    
    So track stuff ourselves.

Diff:
---
 gcc/config/i386/i386.cc | 34 ++++++++++++++++++++--------------
 gcc/config/i386/i386.h  |  1 +
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 4aa37c2ffeaa..23226d204a09 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -6970,7 +6970,7 @@ ix86_compute_frame_layout (void)
     }
 
   frame->save_regs_using_mov
-    = (TARGET_PROLOGUE_USING_MOVE || flag_shrink_wrap_separate) && 
m->use_fast_prologue_epilogue;
+    = (TARGET_PROLOGUE_USING_MOVE /*|| flag_shrink_wrap_separate*/) && 
m->use_fast_prologue_epilogue;
 
   /* Skip return address and error code in exception handler.  */
   offset = INCOMING_FRAME_SP_OFFSET;
@@ -7121,7 +7121,7 @@ ix86_compute_frame_layout (void)
   to_allocate = offset - frame->sse_reg_save_offset;
 
   if ((!to_allocate && frame->nregs <= 1
-       && !flag_shrink_wrap_separate)
+       /*&& !flag_shrink_wrap_separate*/)
       || (TARGET_64BIT && to_allocate >= HOST_WIDE_INT_C (0x80000000))
        /* If static stack checking is enabled and done with probes,
          the registers need to be saved before allocating the frame.  */
@@ -7418,7 +7418,7 @@ ix86_emit_save_regs (void)
   int regno;
   rtx_insn *insn;
 
-  gcc_assert (!crtl->shrink_wrapped_separate);
+  gcc_assert (!cfun->machine->anything_separately);
 
   if (!TARGET_APX_PUSH2POP2
       || !ix86_can_use_push2pop2 ()
@@ -8974,7 +8974,7 @@ ix86_expand_prologue (void)
   if (!int_registers_saved)
     {
       /* If saving registers via PUSH, do so now.  */
-      if (!frame.save_regs_using_mov)
+      if (!frame.save_regs_using_mov && !m->anything_separately)
        {
          ix86_emit_save_regs ();
          int_registers_saved = true;
@@ -9489,7 +9489,7 @@ ix86_emit_restore_regs_using_pop (bool ppx_p)
 {
   unsigned int regno;
 
-  gcc_assert (!crtl->shrink_wrapped_separate);
+  gcc_assert (!cfun->machine->anything_separately);
   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
     if (GENERAL_REGNO_P (regno) && ix86_save_reg (regno, false, true))
       ix86_emit_restore_reg_using_pop (gen_rtx_REG (word_mode, regno), ppx_p);
@@ -9506,7 +9506,7 @@ ix86_emit_restore_regs_using_pop2 (void)
   int loaded_regnum = 0;
   bool aligned = cfun->machine->fs.sp_offset % 16 == 0;
 
-  gcc_assert (!crtl->shrink_wrapped_separate);
+  gcc_assert (!cfun->machine->anything_separately);
   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
     if (GENERAL_REGNO_P (regno) && ix86_save_reg (regno, false, true))
       {
@@ -9894,7 +9894,7 @@ ix86_expand_epilogue (int style)
   /* EH_RETURN requires the use of moves to function properly.  */
   if (crtl->calls_eh_return)
     restore_regs_via_mov = true;
-  else if (crtl->shrink_wrapped_separate)
+  else if (m->anything_separately)
     {
       gcc_assert (!TARGET_SEH);
       restore_regs_via_mov = true;
@@ -10800,13 +10800,14 @@ separate_frame_alloc_p (void)
 static sbitmap
 ix86_get_separate_components (void)
 {
-  struct machine_function *m = cfun->machine;
-  struct ix86_frame *frame = &m->frame;
+  //struct machine_function *m = cfun->machine;
+  //struct ix86_frame *frame = &m->frame;
   sbitmap components;
 
   ix86_finalize_stack_frame_flags ();
-  if (!frame->save_regs_using_mov
-      || crtl->drap_reg)
+  if (/*!frame->save_regs_using_mov
+      ||*/ crtl->drap_reg
+      || cfun->machine->func_type != TYPE_NORMAL)
     return NULL;
 
   components = sbitmap_alloc (NCOMPONENTS);
@@ -11150,6 +11151,8 @@ ix86_process_components (sbitmap components, bool 
prologue_p)
       {
        if (bitmap_bit_p (components, regno))
          {
+           m->reg_wrapped_separately[regno] = true;
+           m->anything_separately = true;
            if (prologue_p)
              ix86_emit_save_reg_using_mov (word_mode, regno, cfa_offset);
            else
@@ -11161,6 +11164,8 @@ ix86_process_components (sbitmap components, bool 
prologue_p)
       {
        if (bitmap_bit_p (components, regno))
          {
+           m->reg_wrapped_separately[regno] = true;
+           m->anything_separately = true;
            if (prologue_p)
              ix86_emit_save_reg_using_mov (V4SFmode, regno, sse_cfa_offset);
            else
@@ -11181,6 +11186,7 @@ ix86_emit_prologue_components (sbitmap components)
   if (bitmap_bit_p (components, SW_FRAME))
     {
       cfun->machine->frame_alloc_separately = true;
+      cfun->machine->anything_separately = true;
       ix86_alloc_frame ();
     }
 }
@@ -11194,11 +11200,11 @@ ix86_emit_epilogue_components (sbitmap components)
 }
 
 static void
-ix86_set_handled_components (sbitmap components)
+ix86_set_handled_components (sbitmap /*components*/)
 {
-  for (unsigned regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
+  /*for (unsigned regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
     if (bitmap_bit_p (components, regno))
-      cfun->machine->reg_wrapped_separately[regno] = true;
+      cfun->machine->reg_wrapped_separately[regno] = true;*/
   /*if (bitmap_bit_p (components, SW_FRAME))
     cfun->machine->frame_alloc_separately = true;*/
 }
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index ad55f5e7222e..dd73687a8e2c 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2752,6 +2752,7 @@ struct GTY(()) machine_function {
   int optimize_mode_switching[MAX_386_ENTITIES];
   bool reg_wrapped_separately[FIRST_PSEUDO_REGISTER];
   bool frame_alloc_separately;
+  bool anything_separately;
 
   /* Cached initial frame layout for the current function.  */
   struct ix86_frame frame;

Reply via email to