On Wed, May 18, 2011 at 8:14 AM, Jakub Jelinek <ja...@redhat.com> wrote:
> Hi!
>
> When an addressable var is optimized into non-addressable, we didn't
> clean up MEM_REFs containing ADDR_EXPR of such VARs in debug stmts.  This
> got later on folded into the var itself and caused ssa verification errors.
> Fixed by trying to rewrite it and if it fails, resetting.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, no change in cc1plus
> .debug_info/.debug_loc, implicitptr.c testcase still works too.
> Ok for trunk/4.6?

Ok.

Thanks,
Richard.

> 2011-05-18  Jakub Jelinek  <ja...@redhat.com>
>
>        PR tree-optimization/49000
>        * tree-ssa.c (execute_update_addresses_taken): Call
>        maybe_rewrite_mem_ref_base on debug stmt value.  If it couldn't
>        be rewritten and decl has been marked for renaming, reset
>        the debug stmt.
>
>        * gcc.dg/pr49000.c: New test.
>
> --- gcc/tree-ssa.c.jj   2011-05-11 19:39:04.000000000 +0200
> +++ gcc/tree-ssa.c      2011-05-17 18:20:10.000000000 +0200
> @@ -2230,6 +2230,17 @@ execute_update_addresses_taken (void)
>                  }
>              }
>
> +           else if (gimple_debug_bind_p (stmt)
> +                    && gimple_debug_bind_has_value_p (stmt))
> +             {
> +               tree *valuep = gimple_debug_bind_get_value_ptr (stmt);
> +               tree decl;
> +               maybe_rewrite_mem_ref_base (valuep);
> +               decl = non_rewritable_mem_ref_base (*valuep);
> +               if (decl && symbol_marked_for_renaming (decl))
> +                 gimple_debug_bind_reset_value (stmt);
> +             }
> +
>            if (gimple_references_memory_p (stmt)
>                || is_gimple_debug (stmt))
>              update_stmt (stmt);
> --- gcc/testsuite/gcc.dg/pr49000.c.jj   2011-05-17 18:30:10.000000000 +0200
> +++ gcc/testsuite/gcc.dg/pr49000.c      2011-05-17 18:23:16.000000000 +0200
> @@ -0,0 +1,29 @@
> +/* PR tree-optimization/49000 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -g" } */
> +
> +static
> +foo (int x, int y)
> +{
> +  return x * y;
> +}
> +
> +static int
> +bar (int *z)
> +{
> +  return *z;
> +}
> +
> +void
> +baz (void)
> +{
> +  int a = 42;
> +  int *b = &a;
> +  foo (bar (&a), 3);
> +}
> +
> +void
> +test (void)
> +{
> +  baz ();
> +}
>
>        Jakub
>

Reply via email to