OSDN Git Service

PR preprocessor/6521
[pf3gnuchains/gcc-fork.git] / gcc / reload1.c
index cf807af..3974e99 100644 (file)
@@ -41,6 +41,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "real.h"
 #include "toplev.h"
 #include "except.h"
+#include "tree.h"
 
 /* This file contains the reload pass of the compiler, which is
    run after register allocation has been done.  It checks that
@@ -1159,9 +1160,9 @@ reload (first, global)
            {
              rtx reg = regno_reg_rtx[i];
 
+             REG_USERVAR_P (reg) = 0;
              PUT_CODE (reg, MEM);
              XEXP (reg, 0) = addr;
-             REG_USERVAR_P (reg) = 0;
              if (reg_equiv_memory_loc[i])
                MEM_COPY_ATTRIBUTES (reg, reg_equiv_memory_loc[i]);
              else
@@ -2067,10 +2068,19 @@ alter_reg (i, from_reg)
         memory.  If this is a shared MEM, make a copy.  */
       if (REGNO_DECL (i))
        {
-         if (from_reg != -1 && spill_stack_slot[from_reg] == x)
-           x = copy_rtx (x);
+         rtx decl = DECL_RTL_IF_SET (REGNO_DECL (i));
 
-         set_mem_expr (x, REGNO_DECL (i));
+         /* We can do this only for the DECLs home pseudo, not for
+            any copies of it, since otherwise when the stack slot
+            is reused, nonoverlapping_memrefs_p might think they
+            cannot overlap.  */
+         if (decl && GET_CODE (decl) == REG && REGNO (decl) == (unsigned) i)
+           {
+             if (from_reg != -1 && spill_stack_slot[from_reg] == x)
+               x = copy_rtx (x);
+
+             set_mem_expr (x, REGNO_DECL (i));
+           }
        }
 
       /* Save the stack slot for later.  */
@@ -2563,7 +2573,7 @@ eliminate_regs (x, mem_mode, insn)
                   )
                  || x_size == new_size)
              )
-           return adjust_address_nv (x, GET_MODE (x), SUBREG_BYTE (x));
+           return adjust_address_nv (new, GET_MODE (x), SUBREG_BYTE (x));
          else
            return gen_rtx_SUBREG (GET_MODE (x), new, SUBREG_BYTE (x));
        }
@@ -8069,7 +8079,8 @@ reload_cse_simplify (insn)
       if (!count && reload_cse_noop_set_p (body))
        {
          rtx value = SET_DEST (body);
-         if (! REG_FUNCTION_VALUE_P (SET_DEST (body)))
+         if (GET_CODE (body) == REG
+             && ! REG_FUNCTION_VALUE_P (SET_DEST (body)))
            value = 0;
          reload_cse_delete_noop_set (insn, value);
          return;