diff mbox

var-tracking wrt. leaf regs on sparc

Message ID 20130207.143818.353212301060219220.davem@davemloft.net
State New
Headers show

Commit Message

David Miller Feb. 7, 2013, 7:38 p.m. UTC
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:

Comments

Jakub Jelinek Feb. 7, 2013, 7:43 p.m. UTC | #1
On Thu, Feb 07, 2013 at 02:38:18PM -0500, David Miller wrote:
> The fix for this is trivial, just a missing leaf renumbering in dwarf2out.c:
> 
> 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))

This and earlier patch are ok, if it bootstraps/regtests fine, and suitable
ChangeLog entry is provided.
Running gdb testsuite before and after wouldn't hurt though.

	Jakub
David Miller Feb. 7, 2013, 11:50 p.m. UTC | #2
From: Jakub Jelinek <jakub@redhat.com>
Date: Thu, 7 Feb 2013 20:43:32 +0100

> This and earlier patch are ok, if it bootstraps/regtests fine, and suitable
> ChangeLog entry is provided.
> Running gdb testsuite before and after wouldn't hurt though.

I've done all of this, and committed to trunk and the gcc-4.7 branch,
thanks.

In looking at the remaining failures, several have to do with
an early clobber if the first incoming argument register.

The issue is that this is where return values are placed, so we run
into a situation where that incoming argument value can't be
reconstituted in any way by the variable tracking code and thus gdb
says that it has been optimized out.

Many non-x86 cpus are going to run into this problem.  For example,
from pr36728-1.c:

foo:
        save    %sp, -96, %sp
        add     %sp, -40, %sp
        mov     2, %g2
        add     %sp, 123, %g1
        mov     25, %g4
        and     %g1, -32, %g1
        sethi   %hi(b), %g3
        st      %g2, [%g1]
        ld      [%fp+92], %g2
        nop
        ld      [%g1], %i0
        add     %g2, 14, %g2
        and     %g2, -8, %g2
        sub     %sp, %g2, %sp
        stb     %g4, [%sp+96]
        add     %sp, 96, %g2
        sethi   %hi(a), %g4
        nop
        return  %i7+8
         nop

Here %i0 is written early, and then the tests can't view 'arg1'
properly later in the function.

Also, I noticed that calculation of the on-stack address of values
with alignment regressed in gcc-4.8 vs. gcc-4.7 Again, in pr36728-1.c,
'y' can be printed properly in gcc-4.7 but in gcc-4.8 it cannot.

I think it might be getting the base register wrong, I'll look
more deeply if I get a chance.
diff mbox

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))