Patchwork Handle MEM_REF with non-zero offset in expand_debug_expr

login
register
mail settings
Submitter Jakub Jelinek
Date Nov. 4, 2010, 9:46 p.m.
Message ID <20101104214646.GC29412@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/70171/
State New
Headers show

Comments

Jakub Jelinek - Nov. 4, 2010, 9:46 p.m.
Hi!

Each of x86_64-linux and i686-linux bootstrap/regtests triggers
MEM_REF with non-zero offset more than 68000 times, so IMNSHO it
is worth to handle it.

Fixed thusly, bootstrapped/regtested it on x86_64-linux and i686-linux, ok
for trunk?

2010-11-04  Jakub Jelinek  <jakub@redhat.com>

	* cfgexpand.c (expand_debug_expr): Handle MEM_REF
	with non-zero offset.


	Jakub
Richard Guenther - Nov. 5, 2010, 10:21 a.m.
On Thu, Nov 4, 2010 at 10:46 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Each of x86_64-linux and i686-linux bootstrap/regtests triggers
> MEM_REF with non-zero offset more than 68000 times, so IMNSHO it
> is worth to handle it.
>
> Fixed thusly, bootstrapped/regtested it on x86_64-linux and i686-linux, ok
> for trunk?

Ok.

Thanks,
Richard.

> 2010-11-04  Jakub Jelinek  <jakub@redhat.com>
>
>        * cfgexpand.c (expand_debug_expr): Handle MEM_REF
>        with non-zero offset.
>
> --- gcc/cfgexpand.c.jj  2010-11-04 20:12:19.000000000 +0100
> +++ gcc/cfgexpand.c     2010-11-04 20:46:12.160386088 +0100
> @@ -2552,15 +2552,20 @@ expand_debug_expr (tree exp)
>       }
>
>     case MEM_REF:
> -      /* ??? FIXME.  */
> -      if (!integer_zerop (TREE_OPERAND (exp, 1)))
> -       return NULL;
> -      /* Fallthru.  */
>     case INDIRECT_REF:
>       op0 = expand_debug_expr (TREE_OPERAND (exp, 0));
>       if (!op0)
>        return NULL;
>
> +      if (TREE_CODE (exp) == MEM_REF)
> +       {
> +         op1 = expand_debug_expr (TREE_OPERAND (exp, 1));
> +         if (!op1 || !CONST_INT_P (op1))
> +           return NULL;
> +
> +         op0 = plus_constant (op0, INTVAL (op1));
> +       }
> +
>       if (POINTER_TYPE_P (TREE_TYPE (exp)))
>        as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)));
>       else
>
>        Jakub
>

Patch

--- gcc/cfgexpand.c.jj	2010-11-04 20:12:19.000000000 +0100
+++ gcc/cfgexpand.c	2010-11-04 20:46:12.160386088 +0100
@@ -2552,15 +2552,20 @@  expand_debug_expr (tree exp)
       }
 
     case MEM_REF:
-      /* ??? FIXME.  */
-      if (!integer_zerop (TREE_OPERAND (exp, 1)))
-	return NULL;
-      /* Fallthru.  */
     case INDIRECT_REF:
       op0 = expand_debug_expr (TREE_OPERAND (exp, 0));
       if (!op0)
 	return NULL;
 
+      if (TREE_CODE (exp) == MEM_REF)
+	{
+	  op1 = expand_debug_expr (TREE_OPERAND (exp, 1));
+	  if (!op1 || !CONST_INT_P (op1))
+	    return NULL;
+
+	  op0 = plus_constant (op0, INTVAL (op1));
+	}
+
       if (POINTER_TYPE_P (TREE_TYPE (exp)))
 	as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)));
       else