Followup for reg_equiv_invariant patch: Fix PR39871

Message ID
State New
Headers show

Commit Message

Bernd Schmidt Sept. 29, 2010, 8:57 p.m.
On 07/31/2010 04:46 PM, Bernd Schmidt wrote:
> On 07/24/2010 03:09 PM, IainS wrote:

> In replace_pseudos_in, we have a series of if statements, which tries to
> pick the correct new home from the various possible alternatives.  This
> seems to need a check for reg_equiv_invariant.
> The other is a crash because when compiling a function with 120 or so
> registers, spilled_pseudos has bit 165 set from the previous function

I finally spent some time debugging why the latter problem happens. We
do clear spilled_pseudos once we're done with the main work inside
reload. When we call replace_pseudos_in to replace a pseudo in a
CALL_INSN_FUNCTION_USAGE, we call eliminate_regs, which will eventually
cause alter_reg to be called if the pseudo is reg_equiv_invariant. We
shouldn't really get into alter_reg at this point; if we do, it sets the
corresponding bit in spilled_pseudos. Fixed by using eliminate_regs_1
instead, with the may_use_invariant arg set to true.

Bootstrapped and regression tested on i686-linux and committed.



Index: ChangeLog
--- ChangeLog	(revision 164732)
+++ ChangeLog	(working copy)
@@ -11,6 +11,11 @@ 
 	costs_add_n_insns): New inline functions.
 	(get_full_rtx_cost): Declare.
+	PR c/45054
+	* reload1.c (replace_pseudos_in): Use eliminate_regs_1, allowing
+	invariants.  Check for reg_equiv_invariant.
+	(reload): Assert that spilled_pseudos is empty when returning.
 2010-09-29  Kai Tietz  <>
 	* config/i386/mingw32.h (TARGET_64BIT): replaced by
Index: reload1.c
--- reload1.c	(revision 164551)
+++ reload1.c	(working copy)
@@ -588,7 +588,7 @@  replace_pseudos_in (rtx *loc, enum machi
       if (regno < FIRST_PSEUDO_REGISTER)
-      x = eliminate_regs (x, mem_mode, usage);
+      x = eliminate_regs_1 (x, mem_mode, usage, true, false);
       if (x != *loc)
 	  *loc = x;
@@ -598,6 +598,8 @@  replace_pseudos_in (rtx *loc, enum machi
       if (reg_equiv_constant[regno])
 	*loc = reg_equiv_constant[regno];
+      else if (reg_equiv_invariant[regno])
+	*loc = reg_equiv_invariant[regno];
       else if (reg_equiv_mem[regno])
 	*loc = reg_equiv_mem[regno];
       else if (reg_equiv_address[regno])
@@ -1316,6 +1318,8 @@  reload (rtx first, int global)
   VEC_free (rtx_p, heap, substitute_stack);
+  gcc_assert (bitmap_empty_p (&spilled_pseudos));
   return failure;