Patchwork var-tracking wrt. leaf regs on sparc

login
register
mail settings
Submitter David Miller
Date Feb. 6, 2013, 8:18 p.m.
Message ID <20130206.151827.2124786527100885863.davem@davemloft.net>
Download mbox | patch
Permalink /patch/218733/
State New
Headers show

Comments

David Miller - Feb. 6, 2013, 8:18 p.m.
From: Eric Botcazou <ebotcazou@adacore.com>
Date: Wed, 06 Feb 2013 11:13:30 +0100

> I think testing crtl->uses_only_leaf_regs is sufficient here (and
> while you're at it, you could also test the value of
> HAVE_window_save, which can be 0 if -mflat is passed on the SPARC),
> so
> 
> #ifdef HAVE_window_save
>     if (HAVE_window_save && !crtl->uses_only_leaf_regs)
>       {
> 
>       }
> #endif

Yes, this works perfectly, Jakub any objections?

gcc/

2013-02-06  David S. Miller  <davem@davemloft.net>

	* var-tracking.c (vt_add_function_parameter): Test the presence of
	HAVE_window_save properly and do not remap argument registers when
	we have a leaf function.
Eric Botcazou - Feb. 6, 2013, 10:12 p.m.
> Yes, this works perfectly, Jakub any objections?
> 
> gcc/
> 
> 2013-02-06  David S. Miller  <davem@davemloft.net>
> 
> 	* var-tracking.c (vt_add_function_parameter): Test the presence of
> 	HAVE_window_save properly and do not remap argument registers when
> 	we have a leaf function.

Please put it on the 4.7 branch as well if approved, this worked (by chance) 
before my change.  TIA.
Jakub Jelinek - Feb. 7, 2013, 5:22 p.m.
On Wed, Feb 06, 2013 at 03:18:27PM -0500, David Miller wrote:
> From: Eric Botcazou <ebotcazou@adacore.com>
> Date: Wed, 06 Feb 2013 11:13:30 +0100
> 
> > I think testing crtl->uses_only_leaf_regs is sufficient here (and
> > while you're at it, you could also test the value of
> > HAVE_window_save, which can be 0 if -mflat is passed on the SPARC),
> > so
> > 
> > #ifdef HAVE_window_save
> >     if (HAVE_window_save && !crtl->uses_only_leaf_regs)
> >       {
> > 
> >       }
> > #endif
> 
> Yes, this works perfectly, Jakub any objections?

Perhaps some progress, but not fully working.  I guess you should start
with deciding when the regs should be remapped.  Consider even
simple testcase like (-O2 -g -dA):

int
foo (int a, int b)
{
  int c = a;
  int d = a + b;
  int e = a + b;
  return e;
}

Before *.vartrack, all debug_insn as well as normal insns refer to
%i0 and %i1, before your patch some NOTE_INSN_VAR_LOCATION were referring
to %o[01] registers, others to %i[01] registers, with your patch all refer
to %i[01] registers.  leaf_renumber_regs isn't performed on notes (so,
neither NOTE_INSN_VAR_LOCATION nor NOTE_INSN_CALL_ARG_LOCATION are
adjusted).  Then supposedly somewhere in dwarf2out we do some adjustment,
but still end up with d/e loclist of:
.LLST2:
        .uaxword        .LVL0-.Ltext0   ! Location list begin address (*.LLST2)
        .uaxword        .LVL1-.Ltext0   ! Location list end address (*.LLST2)
        .uahalf 0x6     ! Location expression size
        .byte   0x88    ! DW_OP_breg24
        .byte   0       ! sleb128 0
        .byte   0x89    ! DW_OP_breg25
        .byte   0       ! sleb128 0
        .byte   0x22    ! DW_OP_plus
        .byte   0x9f    ! DW_OP_stack_value
        .uaxword        .LVL1-.Ltext0   ! Location list begin address (*.LLST2)
        .uaxword        .LFE0-.Ltext0   ! Location list end address (*.LLST2)
        .uahalf 0x1     ! Location expression size
        .byte   0x58    ! DW_OP_reg8
        .uaxword        0       ! Location list terminator begin (*.LLST2)
        .uaxword        0       ! Location list terminator end (*.LLST2)
where I'd expect breg8/breg9 instead.

	Jakub

Patch

diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 714acb69..0db1562 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -9502,31 +9502,34 @@  vt_add_function_parameter (tree parm)
   /* DECL_INCOMING_RTL uses the INCOMING_REGNO of parameter registers.
      If the target machine has an explicit window save instruction, the
      actual entry value is the corresponding OUTGOING_REGNO instead.  */
-  if (REG_P (incoming)
-      && HARD_REGISTER_P (incoming)
-      && OUTGOING_REGNO (REGNO (incoming)) != REGNO (incoming))
+  if (HAVE_window_save && !crtl->uses_only_leaf_regs)
     {
-      parm_reg_t p;
-      p.incoming = incoming;
-      incoming
-	= gen_rtx_REG_offset (incoming, GET_MODE (incoming),
-			      OUTGOING_REGNO (REGNO (incoming)), 0);
-      p.outgoing = incoming;
-      vec_safe_push (windowed_parm_regs, p);
-    }
-  else if (MEM_P (incoming)
-	   && REG_P (XEXP (incoming, 0))
-	   && HARD_REGISTER_P (XEXP (incoming, 0)))
-    {
-      rtx reg = XEXP (incoming, 0);
-      if (OUTGOING_REGNO (REGNO (reg)) != REGNO (reg))
+      if (REG_P (incoming)
+	  && HARD_REGISTER_P (incoming)
+	  && OUTGOING_REGNO (REGNO (incoming)) != REGNO (incoming))
 	{
 	  parm_reg_t p;
-	  p.incoming = reg;
-	  reg = gen_raw_REG (GET_MODE (reg), OUTGOING_REGNO (REGNO (reg)));
-	  p.outgoing = reg;
+	  p.incoming = incoming;
+	  incoming
+	    = gen_rtx_REG_offset (incoming, GET_MODE (incoming),
+				  OUTGOING_REGNO (REGNO (incoming)), 0);
+	  p.outgoing = incoming;
 	  vec_safe_push (windowed_parm_regs, p);
-	  incoming = replace_equiv_address_nv (incoming, reg);
+	}
+      else if (MEM_P (incoming)
+	       && REG_P (XEXP (incoming, 0))
+	       && HARD_REGISTER_P (XEXP (incoming, 0)))
+	{
+	  rtx reg = XEXP (incoming, 0);
+	  if (OUTGOING_REGNO (REGNO (reg)) != REGNO (reg))
+	    {
+	      parm_reg_t p;
+	      p.incoming = reg;
+	      reg = gen_raw_REG (GET_MODE (reg), OUTGOING_REGNO (REGNO (reg)));
+	      p.outgoing = reg;
+	      vec_safe_push (windowed_parm_regs, p);
+	      incoming = replace_equiv_address_nv (incoming, reg);
+	    }
 	}
     }
 #endif