[PATCH] Drop ASM_OPERANDS from var-tracking cselib locations (PR debug/43443)
Richard Guenther
rguenther@suse.de
Mon Mar 22 10:11:00 GMT 2010
On Mon, 22 Mar 2010, Jakub Jelinek wrote:
> Hi!
>
> On
> __attribute__((noinline))
> void bar (void)
> {
> asm volatile ("" : : : "memory");
> }
>
> int
> main (void)
> {
> int i = 6;
> bar ();
> i++;
> asm ("" : "+r" (i));
> i++;
> return i;
> }
> testcase on x86_64-linux -O2 we don't generate location for i near the
> end of function, eventhough the variable is clearly live there and easily
> expressible. The problem is that after the non-volatile asm, value of
> i lives in %eax register, and that register is subsequently modified
> (%eax = %eax + 1). Furthermore the LHS %eax is without i in REG_EXPR,
> as it is the return value already. This means that %eax register is
> dropped from the VALUE's location chain, the VALUE is marked as changed
> and when determining where else it lives it sees ASM_OPERANDS from cselib
> and thus adds VAR_LOCATION note that the value lives in ASM_OPERANDS.
> Of course that isn't something ever expressible in debug info, so i
> is said to live nowhere at that point.
> With the patch below we never consider ASM_OPERANDS in such cases,
> thus the reverse_op stuff can come into play and say where the value
> actually lives even after the increment.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk?
Ok with a testcase.
Thanks,
Richard.
> 2010-03-22 Jakub Jelinek <jakub@redhat.com>
>
> PR debug/43443
> * var-tracking.c (add_cselib_value_chains): Remove ASM_OPERANDS
> locs from preserved VALUEs.
>
> --- gcc/var-tracking.c.jj 2010-03-18 09:35:52.000000000 +0100
> +++ gcc/var-tracking.c 2010-03-19 17:54:12.000000000 +0100
> @@ -2791,15 +2791,23 @@ add_value_chains (decl_or_value dv, rtx
> }
>
> /* If CSELIB_VAL_PTR of value DV refer to VALUEs, add backlinks from those
> - VALUEs to DV. */
> + VALUEs to DV. Add the same time get rid of ASM_OPERANDS from locs list,
> + that is something we never can express in .debug_info and can prevent
> + reverse ops from being used. */
>
> static void
> add_cselib_value_chains (decl_or_value dv)
> {
> - struct elt_loc_list *l;
> + struct elt_loc_list **l;
>
> - for (l = CSELIB_VAL_PTR (dv_as_value (dv))->locs; l; l = l->next)
> - for_each_rtx (&l->loc, add_value_chain, dv_as_opaque (dv));
> + for (l = &CSELIB_VAL_PTR (dv_as_value (dv))->locs; *l;)
> + if (GET_CODE ((*l)->loc) == ASM_OPERANDS)
> + *l = (*l)->next;
> + else
> + {
> + for_each_rtx (&(*l)->loc, add_value_chain, dv_as_opaque (dv));
> + l = &(*l)->next;
> + }
> }
>
> /* If decl or value DVP refers to VALUE from *LOC, remove backlinks
>
> Jakub
>
>
--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex
More information about the Gcc-patches
mailing list