Patchwork var-tracking wrt. leaf regs on sparc

login
register
mail settings
Submitter David Miller
Date Feb. 7, 2013, 7:50 p.m.
Message ID <20130207.145059.238574663050374449.davem@davemloft.net>
Download mbox | patch
Permalink /patch/218983/
State New
Headers show

Comments

David Miller - Feb. 7, 2013, 7:50 p.m.
From: David Miller <davem@davemloft.net>
Date: Thu, 07 Feb 2013 14:38:18 -0500 (EST)

> From: Jakub Jelinek <jakub@redhat.com>
> Date: Thu, 7 Feb 2013 18:22:32 +0100
> 
>> 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.
> 
> The fix for this is trivial, just a missing leaf renumbering in dwarf2out.c:

So the combined patch is below, any objections?

Here is the testsuite diff:

@@ -155,8 +148,8 @@ FAIL: gcc.dg/guality/vla-2.c  -O2 -flto

                === gcc Summary ===

-# of expected passes           2128
-# of unexpected failures       122
+# of expected passes           2135
+# of unexpected failures       115
 # of unexpected successes      31
 # of expected failures         17
 # of unsupported tests         136

This is undoubtedly an improvement.

gcc/

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

	* dwarf2out.c (based_loc_descr): Perform leaf register remapping
	on 'reg'.
	* 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.

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 06cfb18..765d5c5 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10864,7 +10864,16 @@  based_loc_descr (rtx reg, HOST_WIDE_INT offset,
 	}
     }
 
-  regno = DWARF_FRAME_REGNUM (REGNO (reg));
+  regno = REGNO (reg);
+#ifdef LEAF_REG_REMAP
+  if (crtl->uses_only_leaf_regs)
+    {
+      int leaf_reg = LEAF_REG_REMAP (regno);
+      if (leaf_reg != -1)
+	regno = (unsigned) leaf_reg;
+    }
+#endif
+  regno = DWARF_FRAME_REGNUM (regno);
 
   if (!optimize && fde
       && (fde->drap_reg == regno || fde->vdrap_reg == regno))
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