This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C++: Revised patch improving walk_tree and prune_unused_decls a bit


On Tue, Sep 05, 2000 at 10:53:06PM -0700, Zack Weinberg wrote:
> This is a slightly revised version of the patch I posted to gcc-bugs
> earlier today (see thread "Example program takes 2000 times as long to
> compile under C++ as C").  It turns out we still do need to dink with
> the current line number in walk_tree.  The patch is otherwise
> identical.
> 
> The original patch survived a complete bootstrap and testsuite.  This
> one survived the C++ test suite and in addition doesn't mess up
> g++.pt/crash6.C at -O.
> 
...
> Index: cp/tree.c
> --- cp/tree.c	2000/09/05 07:31:27	1.213
> +++ cp/tree.c	2000/09/06 05:50:31
> @@ -1319,7 +1319,8 @@ walk_tree (tp, func, data, htab)
>  	      WALK_SUBTREE (DECL_SIZE_UNIT (DECL_STMT_DECL (*tp)));
>  	    }
>  
> -	  WALK_SUBTREE (TREE_CHAIN (*tp));
> +	  /* This can be tail-recursion optimized if we write it this way.  */
> +	  return walk_tree (&TREE_CHAIN (*tp), func, data, htab);
>  	}

In fact, there are a lot of places in walk_tree where it is not optimized
into tail call. See my patch
http://gcc.gnu.org/ml/gcc-patches/2000-06/msg00696.html
and following discussion.
If you want to go this way, I think my patch (modified to match current
sources) should be applied.
If there is interest, I can revive that patch...
Long term this should be tail recursed, but
there are 2 things which prevent using tail recursion for this, one is the
if (r) return r; else return 0;, the other is the do { } while (0) loop.

	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]