On Fri, 21 Feb 2014, Richard Biener wrote:

> 
> This improves compile-time of PR60291 at -O1 from 210s to 85s,
> getting remove unused locals out of the profile.  There walking
> DECL_INITIAL of globals is quadratic when that is refered to from
> multiple functions.  We've had the same issue with
> add_referenced_vars when that still existed.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk
> and branch?
> 
> I've verified that I can still properly debug
> 
> int **
> foo (void)
> {
>   static int a = 0;
>   static int *b = &a;
>   static int **c = &b;
>   return c;
> }
> int main()
> {
>   return **foo();
> }
> 
> (step into foo and print a, b and c).  Note that even with 4.8
> right now
> 
> int **
> foo (void)
> {
>   int **q;
>     {
>       static int a = 0;
>       static int *b = &a;
>       static int **c = &b;
>       q = c;
>     }
>   return q;
> }
> int main()
> {
>   return **foo();
> }
> 
> is broken (with -O1 -fno-inline, with inlining both cases are
> broken).  But that all doesn't regress with the following and
> if we fix it then we should fix it another way, not by walking
> global initializers.

So I checked if this all is a regression and this particular
piece is a regression from 4.7 where we only walk global
initializers for VAR_DECLs with DECL_CONTEXT == current_function_decl.

So at this point it's easiest and least intrusive to re-instantiate
this restriction which was removed by r187800 (that was me - the
change looks accidential).

Re-bootstrapping / testing on x86_64-unknown-linux-gnu and will
commit afterwards to trunk and to the branch a bit later.

Thanks,
Richard.

2014-02-21  Richard Biener  <rguent...@suse.de>

        PR middle-end/60291
        * tree-ssa-live.c (mark_all_vars_used_1): Do not walk
        DECL_INITIAL for globals not in the current function context.

Index: gcc/tree-ssa-live.c
===================================================================
*** gcc/tree-ssa-live.c (revision 207960)
--- gcc/tree-ssa-live.c (working copy)
*************** mark_all_vars_used_1 (tree *tp, int *wal
*** 435,441 ****
      {
        /* When a global var becomes used for the first time also walk its
           initializer (non global ones don't have any).  */
!       if (set_is_used (t) && is_global_var (t))
        mark_all_vars_used (&DECL_INITIAL (t));
      }
    /* remove_unused_scope_block_p requires information about labels
--- 435,442 ----
      {
        /* When a global var becomes used for the first time also walk its
           initializer (non global ones don't have any).  */
!       if (set_is_used (t) && is_global_var (t)
!         && DECL_CONTEXT (t) == current_function_decl)
        mark_all_vars_used (&DECL_INITIAL (t));
      }
    /* remove_unused_scope_block_p requires information about labels

Reply via email to