[PATCH][C++] Remove 99% calls to expr*location

Richard Guenther rguenther@suse.de
Wed Mar 28 21:32:00 GMT 2007


On Wed, 28 Mar 2007, Richard Guenther wrote:

> On Wed, 28 Mar 2007, Richard Guenther wrote:
> 
> > 
> > This removes 99% of the calls to expr_has_location, expr_locus and
> > expr_location.  Currently the cp_walk_subtrees subroutine saves and
> > restores the input_location for every subtree visited (!) for the
> > appearant reason
> > 
> > -   /* Set input_location here so we get the right instantiation context
> > -      if we call instantiate_decl from inlinable_function_p.  */
> > -   save_locus = input_location;
> > -   if (EXPR_HAS_LOCATION (*tp))
> > -     input_location = EXPR_LOCATION (*tp);
> > 
> > but instantiate_decl is never called from the walk tree, but only from the
> > cannot_inline_tree_fn langhook.  inlinable_function_p looks like:
> > 
> > static bool
> > inlinable_function_p (tree fn)
> > {
> > ...
> >   inlinable = !lang_hooks.tree_inlining.cannot_inline_tree_fn (&fn);
> > ...
> >   else if (inline_forbidden_p (fn))
> >     {
> > ...
> > 
> > where only inline_forbidden_p does a walk_tree.  I fail to see why
> > we should punish 99% of walk_tree just for this case, given that
> > instantiate_decl only writes to input_location as well.
> > 
> > Maybe someone remebers why this was necessary?  The following patch
> > get's all of expr_location stuff off the profiling radar (so no need
> > for me to optimize it, which can be done, too, see the 2nd patch after
> > the first one).
> 
> The locus saving was introduced by the tree-ssa merge and there by
> 
> Branch: 	tree-ssa-20020619-branch
> Changes by:	rth@gcc.gnu.org	2004-04-19 17:38:43
> 
> Modified files:
> 	gcc            : c-common.c 
> 	gcc/cp         : ChangeLog.tree-ssa except.c tree.c 
> 
> Log message:
> 	* c-common.c (c_walk_subtrees): Save and restore input_location.
> 	cp/
> 	* except.c (check_handlers_1): Use locus stored in master for 
> warning.
> 	* tree.c (cp_walk_subtrees): Save and restore input_location.
> 
> but I don't see the c-common.c part ever reached mainline (at least it
> doesn't appear in the tree-ssa changelog) and c_walk_subtree was removed
> by
> 
> 2004-06-26  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
> 
>         * c-common.c (c_safe_from_p, c_walk_subtrees): Deleted.
>         * c-common.def (DECL_STMT): Remove.
>         * c-common.h (DECL_STMT_DECL): Deleted.
>         (COMPOUNT_LITERAL_EXPR_DECL): Use DECL_EXPR_DECL.
>         (c_safe_from_p, c_walk_subtrees): Deleted.
> ...
> 
> -  /* Set input_location here so we get the right instantiation context
> -     if we call instantiate_decl from inlinable_function_p.  */
> -  save_locus = input_location;
> -  if (EXPR_LOCUS (*tp))
> -    input_location = *EXPR_LOCUS (*tp);
> 
> so maybe it's just an oversight the cp variant survived?

So bootstrap and regtest on x86_64-unknown-linux-gnu succeeded.

Richard.



More information about the Gcc-patches mailing list