]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Cache the set of EH_RETURN_DATA_REGNOs
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 21 May 2024 09:21:16 +0000 (10:21 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 21 May 2024 09:21:16 +0000 (10:21 +0100)
While reviewing Andrew's fix for PR114843, it seemed like it would
be convenient to have a HARD_REG_SET of EH_RETURN_DATA_REGNOs.
This patch adds one and uses it to simplify a couple of use sites.

gcc/
* hard-reg-set.h (target_hard_regs::x_eh_return_data_regs): New field.
(eh_return_data_regs): New macro.
* reginfo.cc (init_reg_sets_1): Initialize x_eh_return_data_regs.
* df-scan.cc (df_get_exit_block_use_set): Use it.
* ira-lives.cc (process_out_of_region_eh_regs): Likewise.

gcc/df-scan.cc
gcc/hard-reg-set.h
gcc/ira-lives.cc
gcc/reginfo.cc

index 1bade2cd71e2b0d13a89faabefdc87a4b061058c..c8ab3c09cee28a73b3adc57a46f32aea90807394 100644 (file)
@@ -3702,13 +3702,7 @@ df_get_exit_block_use_set (bitmap exit_block_uses)
 
   /* Mark the registers that will contain data for the handler.  */
   if (reload_completed && crtl->calls_eh_return)
-    for (i = 0; ; ++i)
-      {
-       unsigned regno = EH_RETURN_DATA_REGNO (i);
-       if (regno == INVALID_REGNUM)
-         break;
-       bitmap_set_bit (exit_block_uses, regno);
-      }
+    IOR_REG_SET_HRS (exit_block_uses, eh_return_data_regs);
 
 #ifdef EH_RETURN_STACKADJ_RTX
   if ((!targetm.have_epilogue () || ! epilogue_completed)
index 8c1d1512ca2de38f394e9ee6959c3bfc298635a2..340eb425c1051430ff065e4ea6791c0f0ad7bdfa 100644 (file)
@@ -421,6 +421,9 @@ struct target_hard_regs {
      with the local stack frame are safe, but scant others.  */
   HARD_REG_SET x_regs_invalidated_by_call;
 
+  /* The set of registers that are used by EH_RETURN_DATA_REGNO.  */
+  HARD_REG_SET x_eh_return_data_regs;
+
   /* Table of register numbers in the order in which to try to use them.  */
   int x_reg_alloc_order[FIRST_PSEUDO_REGISTER];
 
@@ -485,6 +488,8 @@ extern struct target_hard_regs *this_target_hard_regs;
 #define call_used_or_fixed_regs \
   (regs_invalidated_by_call | fixed_reg_set)
 #endif
+#define eh_return_data_regs \
+  (this_target_hard_regs->x_eh_return_data_regs)
 #define reg_alloc_order \
   (this_target_hard_regs->x_reg_alloc_order)
 #define inv_reg_alloc_order \
index e07d3dc3e895fa3d32735d30bda208655f91dd81..958eabb97082b89b4570e2118330d55e435eea60 100644 (file)
@@ -1260,14 +1260,8 @@ process_out_of_region_eh_regs (basic_block bb)
       for (int n = ALLOCNO_NUM_OBJECTS (a) - 1; n >= 0; n--)
        {
          ira_object_t obj = ALLOCNO_OBJECT (a, n);
-         for (int k = 0; ; k++)
-           {
-             unsigned int regno = EH_RETURN_DATA_REGNO (k);
-             if (regno == INVALID_REGNUM)
-               break;
-             SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno);
-             SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), regno);
-           }
+         OBJECT_CONFLICT_HARD_REGS (obj) |= eh_return_data_regs;
+         OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) |= eh_return_data_regs;
        }
     }
 }
index a0baeb90e1203560e8d7a42e45fbf12eeeb9aaa4..73121365c4776309e7f755be5240552f6a2070fa 100644 (file)
@@ -420,6 +420,16 @@ init_reg_sets_1 (void)
        }
     }
 
+  /* Recalculate eh_return_data_regs.  */
+  CLEAR_HARD_REG_SET (eh_return_data_regs);
+  for (i = 0; ; ++i)
+    {
+      unsigned int regno = EH_RETURN_DATA_REGNO (i);
+      if (regno == INVALID_REGNUM)
+       break;
+      SET_HARD_REG_BIT (eh_return_data_regs, regno);
+    }
+
   memset (have_regs_of_mode, 0, sizeof (have_regs_of_mode));
   memset (contains_reg_of_mode, 0, sizeof (contains_reg_of_mode));
   for (m = 0; m < (unsigned int) MAX_MACHINE_MODE; m++)