]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
reload1.c (reload): Make all entries in reg_equiv_memory_loc unshared.
authorHans-Peter Nilsson <hp@bitrange.com>
Sat, 25 Aug 2001 21:39:47 +0000 (21:39 +0000)
committerHans-Peter Nilsson <hp@gcc.gnu.org>
Sat, 25 Aug 2001 21:39:47 +0000 (21:39 +0000)
* reload1.c (reload): Make all entries in reg_equiv_memory_loc
unshared.
* reload.c (make_memloc): Copy result if it is still
reg_equiv_memory_loc[regno] on return.
(subst_reloads) [ENABLE_CHECKING]: Check that none of
reg_equiv_constant, reg_equiv_memory_loc, reg_equiv_address and
reg_equiv_mem are modified by the substitutions.

From-SVN: r45177

gcc/ChangeLog
gcc/reload.c
gcc/reload1.c

index 4b32717d194af090f7931a7701391b49761c8892..f85e3d22d04d1e49c26405220378fcf51508ad01 100644 (file)
@@ -1,3 +1,13 @@
+2001-08-25  Hans-Peter Nilsson  <hp@bitrange.com>
+
+       * reload1.c (reload): Make all entries in reg_equiv_memory_loc
+       unshared.
+       * reload.c (make_memloc): Copy result if it is still
+       reg_equiv_memory_loc[regno] on return.
+       (subst_reloads) [ENABLE_CHECKING]: Check that none of
+       reg_equiv_constant, reg_equiv_memory_loc, reg_equiv_address and
+       reg_equiv_mem are modified by the substitutions.
+
 Sat Aug 25 23:07:35 CEST 2001  Jan Hubicka  <jh@suse.cz>
 
        * predict.c (expensive_function_p): New.
index 73f8b2185ec41b0ba1f2ff48d896567da9cb1dd1..0cf5a0eebf97558b2d144457ea2cf7a5dd4472ec 100644 (file)
@@ -4486,7 +4486,13 @@ make_memloc (ad, regno)
     tem = copy_rtx (tem);
 
   tem = replace_equiv_address_nv (reg_equiv_memory_loc[regno], tem);
-  return adjust_address_nv (tem, GET_MODE (ad), 0);
+  tem = adjust_address_nv (tem, GET_MODE (ad), 0);
+
+  /* Copy the result if it's still the same as the equivalence, to avoid
+     modifying it when we do the substitution for the reload.  */
+  if (tem == reg_equiv_memory_loc[regno])
+    tem = copy_rtx (tem);
+  return tem;
 }
 
 /* Record all reloads needed for handling memory address AD
@@ -5769,6 +5775,32 @@ subst_reloads (insn)
       register rtx reloadreg = rld[r->what].reg_rtx;
       if (reloadreg)
        {
+#ifdef ENABLE_CHECKING
+         /* Internal consistency test.  Check that we don't modify
+            anything in the equivalence arrays.  Whenever something from
+            those arrays needs to be reloaded, it must be unshared before
+            being substituted into; the equivalence must not be modified.
+            Otherwise, if the equivalence is used after that, it will
+            have been modified, and the thing substituted (probably a
+            register) is likely overwritten and not a usable equivalence.  */
+         int check_regno;
+
+         for (check_regno = 0; check_regno < max_regno; check_regno++)
+           {
+#define CHECK_MODF(ARRAY)                                              \
+             if (ARRAY[check_regno]                                    \
+                 && loc_mentioned_in_p (r->where,                      \
+                                        ARRAY[check_regno]))           \
+               abort ()
+
+             CHECK_MODF (reg_equiv_constant);
+             CHECK_MODF (reg_equiv_memory_loc);
+             CHECK_MODF (reg_equiv_address);
+             CHECK_MODF (reg_equiv_mem);
+#undef CHECK_MODF
+           }
+#endif /* ENABLE_CHECKING */
+
          /* If we're replacing a LABEL_REF with a register, add a
             REG_LABEL note to indicate to flow which label this
             register refers to.  */
index 51a2ba90f9b92b0d4f3fa313b7bfac8c747d856f..83708400422419572a5d265e12e19ee51825b88e 100644 (file)
@@ -782,12 +782,10 @@ reload (first, global)
                {
                  if (GET_CODE (x) == MEM)
                    {
-                     /* If the operand is a PLUS, the MEM may be shared,
-                        so make sure we have an unshared copy here.  */
-                     if (GET_CODE (XEXP (x, 0)) == PLUS)
-                       x = copy_rtx (x);
-
-                     reg_equiv_memory_loc[i] = x;
+                     /* Always unshare the equivalence, so we can
+                        substitute into this insn without touching the
+                        equivalence. */
+                     reg_equiv_memory_loc[i] = copy_rtx (x);
                    }
                  else if (function_invariant_p (x))
                    {