[PATCH] Try to canonicalize MEM_REFs that are put into MEM_EXPRs for DEBUG_INSNs (PR debug/47283)

Richard Henderson rth@redhat.com
Thu Mar 3 05:32:00 GMT 2011


On 03/03/2011 03:40 AM, Jakub Jelinek wrote:
> Hi!
> 
> The pr47283.C testcase was still failing on ia64-linux, there
> the var in question was given a stack slot, but ICEs were caused by
> non-canonical MEM_REF in MEM_EXPR of DEBUG_INSN MEM.  In particular
> there was MEM_REF <ADDR_EXPR <COMPONENT_REF <...> >, 0> on which aliasing
> code ICEd.  This patch tries to canonicalize it, and if the canonicalization
> wasn't sufficient, uses just type and not the MEM_REF for
> set_mem_attributes.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2011-03-02  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR debug/47283
> 	* cfgexpand.c (expand_debug_expr) <case MEM_REF>: If MEM_REF
> 	first operand is not is_gimple_mem_ref_addr, try to fold it.
> 	If the operand still isn't is_gimple_mem_ref_addr, pass just
> 	its type to set_mem_attributes.
> 
> --- gcc/cfgexpand.c.jj	2011-02-21 15:37:42.000000000 +0100
> +++ gcc/cfgexpand.c	2011-03-02 11:05:32.000000000 +0100
> @@ -2578,11 +2578,25 @@ expand_debug_expr (tree exp)
>        }
>  
>      case MEM_REF:
> +      if (!is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0)))
> +	{
> +	  tree newexp = fold_binary (MEM_REF, TREE_TYPE (exp),
> +				     TREE_OPERAND (exp, 0),
> +				     TREE_OPERAND (exp, 1));
> +	  if (newexp)
> +	    exp = newexp;
> +	}
> +      /* FALLTHROUGH */
>      case INDIRECT_REF:

Do you really want to fallthru with newexp here?
In theory it could have folded to anything.  My guess is that
you want to restart instead...


r~



More information about the Gcc-patches mailing list