[PR41276, PR41307] don't leak VALUEs into VAR_LOCATION NOTEs

Jakub Jelinek jakub@redhat.com
Tue Sep 8 16:15:00 GMT 2009


On Tue, Sep 08, 2009 at 12:40:11PM -0300, Alexandre Oliva wrote:
> When a VALUE in var-tracking expands to a hard reg, and we want a subreg
> of that value but the hard reg can't hold that mode, we end up returning
> the original subreg of a value, which is inappropriate.
> 
> This patch ensures that we don't.  I'm going to check it in as obvious.
> 

> for  gcc/ChangeLog
> from  Alexandre Oliva  <aoliva@redhat.com>
> 
> 	PR debug/41276
> 	PR debug/41307
> 	* cselib.c (cselib_expand_value_rtx_1): Don't return copy of
> 	invalid subreg.
> 
> Index: gcc/cselib.c
> ===================================================================
> --- gcc/cselib.c.orig	2009-09-07 06:49:48.000000000 -0300
> +++ gcc/cselib.c	2009-09-07 06:50:06.000000000 -0300
> @@ -1165,12 +1165,12 @@ cselib_expand_value_rtx_1 (rtx orig, str
>  	scopy = simplify_gen_subreg (GET_MODE (orig), subreg,
>  				     GET_MODE (SUBREG_REG (orig)),
>  				     SUBREG_BYTE (orig));
> -	if (scopy == NULL
> -	    || (GET_CODE (scopy) == SUBREG
> -		&& !REG_P (SUBREG_REG (scopy))
> -		&& !MEM_P (SUBREG_REG (scopy))
> -		&& (REG_P (SUBREG_REG (orig))
> -		    || MEM_P (SUBREG_REG (orig)))))
> +	if ((scopy == NULL
> +	     || (GET_CODE (scopy) == SUBREG
> +		 && !REG_P (SUBREG_REG (scopy))
> +		 && !MEM_P (SUBREG_REG (scopy))))
> +	    && (REG_P (SUBREG_REG (orig))
> +		|| MEM_P (SUBREG_REG (orig))))
>  	  return shallow_copy_rtx (orig);
>  	return scopy;
>        }

I think this still isn't right, whenever we shallow_copy_rtx (orig),
its SUBREG_REG will still be invalidly shared (think of MEM with some fancy
address inside it, could even have VALUE in its address and leak to
dwarf2out).

The important question is, do we want less pedantic rules for SUBREGs
in DEBUG_INSNs?  I believe so, already now VTA creates all kinds of stuff in
SUBREG and dwarf2out.c is able to deal with it (there is no
validation performed on DEBUG_INSN argument).  So, for evd->callback != NULL we
could just gen_rtx_SUBREG if simplify_gen_subreg failed, dwarf2out will
still handle it as low part of some register.  And otherwise (for DSE
purposes) we should just return NULL, otherwise we might end up with invalid
RTL sharing.

	Jakub



More information about the Gcc-patches mailing list