[RFC, PATCH] Getting the live registers correct when caller-saves are inserted by reload

Hans-Peter Nilsson hans-peter.nilsson@axis.com
Tue Dec 4 02:51:00 GMT 2007


> Date: Fri, 23 Nov 2007 16:10:15 +0530
> From: Pranav Bhandarkar <pranav.bhandarkar@celunite.com>

> >> 2007-11-15  Pranav Bhandarkar  <pranav.bhandarkar@celunite.com>
> >>
> >>     * caller-save.c (insert_one_insn): If inserting before a call_insn
> >>     then the registers containing the arguments of the call are
> >>     live_throughout in the new insn.
> >>     
> >
> > This is OK.  Thanks.
> >   
> Thanks, but I'll need someone to commit this.

I've stumbled on this bug too, and I intend to commit the
following update after testing.  For the record, I see Celunite
has copyright assignment on file.

I fixed a new formatting issues (spacing in comment and 80
column wrap) and changed the regno test to be a bit safer, the
same as in the loop above this code.  As follows:

Index: caller-save.c
===================================================================
--- caller-save.c	(revision 130398)
+++ caller-save.c	(working copy)
@@ -850,6 +850,37 @@ insert_one_insn (struct insn_chain *chai
 		SET_REGNO_REG_SET (&new->live_throughout, regno + i);
 	    }
 	}
+
+      /* If CHAIN->INSN is a call, then the registers which contain
+	 the arguments to the function are live in the new insn.  */
+      if (CALL_P (chain->insn))
+	{
+	  for (link = CALL_INSN_FUNCTION_USAGE (chain->insn);
+	       link != NULL_RTX;
+	       link = XEXP (link, 1))
+	    {
+	      rtx arg = XEXP (link, 0);
+
+	      if (GET_CODE (arg) == USE)
+		{
+		  rtx reg = XEXP (arg, 0);
+
+		  if (REG_P (reg))
+		    {
+		      int i, regno = REGNO (reg);
+		      if (regno >= FIRST_PSEUDO_REGISTER)
+			regno = reg_renumber[regno];
+		      if (regno < 0)
+			continue;
+		      for (i = hard_regno_nregs[regno][GET_MODE (reg)] - 1;
+			   i >= 0; i--)
+			SET_REGNO_REG_SET (&new->live_throughout, regno + i);
+		    }
+		}
+	    }
+	  
+	}
+
       CLEAR_REG_SET (&new->dead_or_set);
       if (chain->insn == BB_HEAD (BASIC_BLOCK (chain->block)))
 	BB_HEAD (BASIC_BLOCK (chain->block)) = new->insn;


brgds, H-P



More information about the Gcc-patches mailing list