* [PATCH][C++/Java] Get rid of the walk_subtrees langhook
@ 2007-07-26 14:32 Richard Guenther
2007-07-26 16:35 ` Andrew Haley
2007-08-06 0:24 ` Mark Mitchell
0 siblings, 2 replies; 4+ messages in thread
From: Richard Guenther @ 2007-07-26 14:32 UTC (permalink / raw)
To: gcc-patches
This gets rid of the walk_subtrees langhook which is called at every
invocation of walk_trees. The only real user is the C++ frontend which
is too lazy to use its own walk_tree. Instead of duplicating walk_tree
there I made the langhook an extra callback parameter for walk_tree
and replaced all occurances in the C++ frontend by a wrapper called
cp_walk_tree that passes the current langhook implementation. All
cases covered in the langhook look frontend specific and should not
affect middle-end walkers.
Apart from nice to LTO this should bring a noticable speedup for
targets with slow indirect calls.
Full bootstrap and regtest on x86_64-unknown-linux-gnu still running
for C++ and Java, though build and C++ testing finished successfully
already.
Ok for mainline? (This needs a GWP at best)
Note I did not go through callers to walk_tree in the C++ frontend
to identify which ones really need the callback but just changed them
all over.
Thanks,
Richard.
2007-07-26 Richard Guenther <rguenther@suse.de>
* tree.c (WALK_SUBTREE): Call walk_tree_1.
(walk_type_fields): Take lh parameter.
(walk_tree): Rename to ...
(walk_tree_1): ... this. Do not call the walk_subtrees
langhook but the now passed callback. Pass lh on recursion.
(walk_tree_without_duplicates): Rename to ...
(walk_tree_without_duplicates_1): ... this. Take lh parameter
and call walk_tree_1.
* tree.h (walk_tree_lh): New typedef.
(walk_tree_1): Declare.
(walk_tree_without_duplicates_1): Likewise.
(walk_tree): New define to walk_tree_1 with NULL lh parameter.
(walk_tree_without_duplicates): New define to
walk_tree_without_duplicates_1 with NULL lh parameter.
* langhooks.c (lhd_tree_inlining_walk_subtrees): Remove.
* langhooks.h (lang_hooks_for_tree_inlining): Remove walk_subtrees
langhook.
* langhooks-def.h (lhd_tree_inlining_walk_subtrees): Remove.
(LANG_HOOKS_TREE_INLINING_WALK_SUBTREES): Likewise.
(LANG_HOOKS_TREE_INLINING_INITIALIZER): Remove walk_subtrees
initializer.
java/
* lang.c (java_tree_inlining_walk_subtrees): Remove.
(LANG_HOOKS_TREE_INLINING_WALK_SUBTREES): Remove.
cp/
* cp-objcp-common.h (LANG_HOOKS_TREE_INLINING_WALK_SUBTREES):
Remove define.
* tree.h (cp_walk_tree): New define to walk_tree_1 with
cp_walk_subtrees lh parameter.
(cp_walk_tree_without_duplicates): New define to
walk_tree_without_duplicates_1 with cp_walk_subtrees lh parameter.
* tree.c (count_trees): Call
cp_walk_tree_without_duplicates.
(verify_stmt_tree): Call cp_walk_tree.
(break_out_target_exprs): Likewise.
(WALK_SUBTREE): Likewise.
* cp-gimplify.c (cp_genericize): Likewise.
* cp-pt.c (find_parameter_packs_r): Likewise.
(uses_parameter_packs): Likewise.
(make_pack_expansion): Likewise.
(check_for_bare_parameter_packs): Likewise.
(for_each_template_parm): Likewise.
* decl.c (check_default_argument): Call
cp_walk_tree_without_duplicates.
* except.c (build_throw): Likewise.
* decl2.c (type_visibility): Likewise.
* semantics.c (expand_or_defer_fn): Likewise.
(finalize_nrv): Call cp_walk_tree.
Index: tree.c
===================================================================
*** tree.c (revision 126953)
--- tree.c (working copy)
*************** num_ending_zeros (const_tree x)
*** 8061,8067 ****
#define WALK_SUBTREE(NODE) \
do \
{ \
! result = walk_tree (&(NODE), func, data, pset); \
if (result) \
return result; \
} \
--- 8061,8067 ----
#define WALK_SUBTREE(NODE) \
do \
{ \
! result = walk_tree_1 (&(NODE), func, data, pset, lh); \
if (result) \
return result; \
} \
*************** num_ending_zeros (const_tree x)
*** 8073,8079 ****
static tree
walk_type_fields (tree type, walk_tree_fn func, void *data,
! struct pointer_set_t *pset)
{
tree result = NULL_TREE;
--- 8073,8079 ----
static tree
walk_type_fields (tree type, walk_tree_fn func, void *data,
! struct pointer_set_t *pset, walk_tree_lh lh)
{
tree result = NULL_TREE;
*************** walk_type_fields (tree type, walk_tree_f
*** 8153,8159 ****
and to avoid visiting a node more than once. */
tree
! walk_tree (tree *tp, walk_tree_fn func, void *data, struct pointer_set_t *pset)
{
enum tree_code code;
int walk_subtrees;
--- 8153,8160 ----
and to avoid visiting a node more than once. */
tree
! walk_tree_1 (tree *tp, walk_tree_fn func, void *data,
! struct pointer_set_t *pset, walk_tree_lh lh)
{
enum tree_code code;
int walk_subtrees;
*************** walk_tree (tree *tp, walk_tree_fn func,
*** 8200,8209 ****
return NULL_TREE;
}
! result = lang_hooks.tree_inlining.walk_subtrees (tp, &walk_subtrees, func,
! data, pset);
! if (result || !walk_subtrees)
! return result;
switch (code)
{
--- 8201,8212 ----
return NULL_TREE;
}
! if (lh)
! {
! result = (*lh) (tp, &walk_subtrees, func, data, pset);
! if (result || !walk_subtrees)
! return result;
! }
switch (code)
{
*************** walk_tree (tree *tp, walk_tree_fn func,
*** 8356,8362 ****
if (result || !walk_subtrees)
return result;
! result = walk_type_fields (*type_p, func, data, pset);
if (result)
return result;
--- 8359,8365 ----
if (result || !walk_subtrees)
return result;
! result = walk_type_fields (*type_p, func, data, pset, lh);
if (result)
return result;
*************** walk_tree (tree *tp, walk_tree_fn func,
*** 8420,8426 ****
}
/* If this is a type, walk the needed fields in the type. */
else if (TYPE_P (*tp))
! return walk_type_fields (*tp, func, data, pset);
break;
}
--- 8423,8429 ----
}
/* If this is a type, walk the needed fields in the type. */
else if (TYPE_P (*tp))
! return walk_type_fields (*tp, func, data, pset, lh);
break;
}
*************** walk_tree (tree *tp, walk_tree_fn func,
*** 8434,8446 ****
/* Like walk_tree, but does not walk duplicate nodes more than once. */
tree
! walk_tree_without_duplicates (tree *tp, walk_tree_fn func, void *data)
{
tree result;
struct pointer_set_t *pset;
pset = pointer_set_create ();
! result = walk_tree (tp, func, data, pset);
pointer_set_destroy (pset);
return result;
}
--- 8437,8450 ----
/* Like walk_tree, but does not walk duplicate nodes more than once. */
tree
! walk_tree_without_duplicates_1 (tree *tp, walk_tree_fn func, void *data,
! walk_tree_lh lh)
{
tree result;
struct pointer_set_t *pset;
pset = pointer_set_create ();
! result = walk_tree_1 (tp, func, data, pset, lh);
pointer_set_destroy (pset);
return result;
}
Index: tree.h
===================================================================
*** tree.h (revision 126953)
--- tree.h (working copy)
*************** struct pointer_set_t;
*** 4806,4813 ****
/* The type of a callback function for walking over tree structure. */
typedef tree (*walk_tree_fn) (tree *, int *, void *);
! extern tree walk_tree (tree*, walk_tree_fn, void*, struct pointer_set_t*);
! extern tree walk_tree_without_duplicates (tree*, walk_tree_fn, void*);
/* Assign the RTX to declaration. */
--- 4806,4821 ----
/* The type of a callback function for walking over tree structure. */
typedef tree (*walk_tree_fn) (tree *, int *, void *);
! typedef tree (*walk_tree_lh) (tree *, int *, tree (*) (tree *, int *, void *),
! void *, struct pointer_set_t*);
! extern tree walk_tree_1 (tree*, walk_tree_fn, void*, struct pointer_set_t*,
! walk_tree_lh);
! extern tree walk_tree_without_duplicates_1 (tree*, walk_tree_fn, void*,
! walk_tree_lh);
! #define walk_tree(a,b,c,d) \
! walk_tree_1 (a, b, c, d, NULL)
! #define walk_tree_without_duplicates(a,b,c) \
! walk_tree_without_duplicates_1 (a, b, c, NULL)
/* Assign the RTX to declaration. */
Index: cp/decl.c
===================================================================
*** cp/decl.c (revision 126953)
--- cp/decl.c (working copy)
*************** check_default_argument (tree decl, tree
*** 9061,9068 ****
The keyword `this' shall not be used in a default argument of a
member function. */
! var = walk_tree_without_duplicates (&arg, local_variable_p_walkfn,
! NULL);
if (var)
{
error ("default argument %qE uses local variable %qD", arg, var);
--- 9061,9067 ----
The keyword `this' shall not be used in a default argument of a
member function. */
! var = cp_walk_tree_without_duplicates (&arg, local_variable_p_walkfn, NULL);
if (var)
{
error ("default argument %qE uses local variable %qD", arg, var);
Index: cp/except.c
===================================================================
*** cp/except.c (revision 126953)
--- cp/except.c (working copy)
*************** build_throw (tree exp)
*** 783,789 ****
we don't have to do them during unwinding. But first wrap
them in MUST_NOT_THROW_EXPR, since they are run after the
exception object is initialized. */
! walk_tree_without_duplicates (&temp_expr, wrap_cleanups_r, 0);
exp = build2 (COMPOUND_EXPR, TREE_TYPE (exp), temp_expr, exp);
exp = build1 (CLEANUP_POINT_EXPR, TREE_TYPE (exp), exp);
}
--- 783,789 ----
we don't have to do them during unwinding. But first wrap
them in MUST_NOT_THROW_EXPR, since they are run after the
exception object is initialized. */
! cp_walk_tree_without_duplicates (&temp_expr, wrap_cleanups_r, 0);
exp = build2 (COMPOUND_EXPR, TREE_TYPE (exp), temp_expr, exp);
exp = build1 (CLEANUP_POINT_EXPR, TREE_TYPE (exp), exp);
}
Index: cp/cp-objcp-common.h
===================================================================
*** cp/cp-objcp-common.h (revision 126953)
--- cp/cp-objcp-common.h (working copy)
*************** extern tree objcp_tsubst_copy_and_build
*** 105,113 ****
#undef LANG_HOOKS_ATTRIBUTE_TABLE
#define LANG_HOOKS_ATTRIBUTE_TABLE cxx_attribute_table
- #undef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES
- #define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES \
- cp_walk_subtrees
#undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
cp_cannot_inline_tree_fn
--- 105,110 ----
Index: cp/tree.c
===================================================================
*** cp/tree.c (revision 126953)
--- cp/tree.c (working copy)
*************** int
*** 1281,1287 ****
count_trees (tree t)
{
int n_trees = 0;
! walk_tree_without_duplicates (&t, count_trees_r, &n_trees);
return n_trees;
}
--- 1281,1287 ----
count_trees (tree t)
{
int n_trees = 0;
! cp_walk_tree_without_duplicates (&t, count_trees_r, &n_trees);
return n_trees;
}
*************** verify_stmt_tree (tree t)
*** 1318,1324 ****
{
htab_t statements;
statements = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
! walk_tree (&t, verify_stmt_tree_r, &statements, NULL);
htab_delete (statements);
}
--- 1318,1324 ----
{
htab_t statements;
statements = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
! cp_walk_tree (&t, verify_stmt_tree_r, &statements, NULL);
htab_delete (statements);
}
*************** break_out_target_exprs (tree t)
*** 1520,1527 ****
target_remap = splay_tree_new (splay_tree_compare_pointers,
/*splay_tree_delete_key_fn=*/NULL,
/*splay_tree_delete_value_fn=*/NULL);
! walk_tree (&t, bot_manip, target_remap, NULL);
! walk_tree (&t, bot_replace, target_remap, NULL);
if (!--target_remap_count)
{
--- 1520,1527 ----
target_remap = splay_tree_new (splay_tree_compare_pointers,
/*splay_tree_delete_key_fn=*/NULL,
/*splay_tree_delete_value_fn=*/NULL);
! cp_walk_tree (&t, bot_manip, target_remap, NULL);
! cp_walk_tree (&t, bot_replace, target_remap, NULL);
if (!--target_remap_count)
{
*************** cp_walk_subtrees (tree *tp, int *walk_su
*** 2289,2295 ****
#define WALK_SUBTREE(NODE) \
do \
{ \
! result = walk_tree (&(NODE), func, data, pset); \
if (result) goto out; \
} \
while (0)
--- 2289,2295 ----
#define WALK_SUBTREE(NODE) \
do \
{ \
! result = cp_walk_tree (&(NODE), func, data, pset); \
if (result) goto out; \
} \
while (0)
Index: cp/cp-tree.h
===================================================================
*** cp/cp-tree.h (revision 126953)
--- cp/cp-tree.h (working copy)
*************** extern void verify_stmt_tree (tree);
*** 4725,4730 ****
--- 4725,4734 ----
extern linkage_kind decl_linkage (tree);
extern tree cp_walk_subtrees (tree*, int*, walk_tree_fn,
void*, struct pointer_set_t*);
+ #define cp_walk_tree(a,b,c,d) \
+ walk_tree_1 (a, b, c, d, cp_walk_subtrees)
+ #define cp_walk_tree_without_duplicates(a,b,c) \
+ walk_tree_without_duplicates_1 (a, b, c, cp_walk_subtrees)
extern int cp_cannot_inline_tree_fn (tree*);
extern int cp_auto_var_in_fn_p (tree,tree);
extern tree fold_if_not_in_template (tree);
Index: cp/cp-gimplify.c
===================================================================
*** cp/cp-gimplify.c (revision 126953)
--- cp/cp-gimplify.c (working copy)
*************** cp_genericize (tree fndecl)
*** 746,752 ****
/* We do want to see every occurrence of the parms, so we can't just use
walk_tree's hash functionality. */
p_set = pointer_set_create ();
! walk_tree (&DECL_SAVED_TREE (fndecl), cp_genericize_r, p_set, NULL);
pointer_set_destroy (p_set);
/* Do everything else. */
--- 746,752 ----
/* We do want to see every occurrence of the parms, so we can't just use
walk_tree's hash functionality. */
p_set = pointer_set_create ();
! cp_walk_tree (&DECL_SAVED_TREE (fndecl), cp_genericize_r, p_set, NULL);
pointer_set_destroy (p_set);
/* Do everything else. */
Index: cp/pt.c
===================================================================
*** cp/pt.c (revision 126953)
--- cp/pt.c (working copy)
*************** find_parameter_packs_r (tree *tp, int *w
*** 2392,2398 ****
if (TYPE_P (t))
{
tree context = TYPE_CONTEXT (t);
! walk_tree (&context, &find_parameter_packs_r, ppd, ppd->visited);
}
/* This switch statement will return immediately if we don't find a
--- 2392,2398 ----
if (TYPE_P (t))
{
tree context = TYPE_CONTEXT (t);
! cp_walk_tree (&context, &find_parameter_packs_r, ppd, ppd->visited);
}
/* This switch statement will return immediately if we don't find a
*************** find_parameter_packs_r (tree *tp, int *w
*** 2406,2413 ****
case BOUND_TEMPLATE_TEMPLATE_PARM:
/* Check the template arguments. */
! walk_tree (&TYPE_TI_ARGS (t), &find_parameter_packs_r, ppd,
! ppd->visited);
/* Dig out the underlying TEMPLATE_TEMPLATE_PARM. */
t = TYPE_TI_TEMPLATE (t);
--- 2406,2413 ----
case BOUND_TEMPLATE_TEMPLATE_PARM:
/* Check the template arguments. */
! cp_walk_tree (&TYPE_TI_ARGS (t), &find_parameter_packs_r, ppd,
! ppd->visited);
/* Dig out the underlying TEMPLATE_TEMPLATE_PARM. */
t = TYPE_TI_TEMPLATE (t);
*************** find_parameter_packs_r (tree *tp, int *w
*** 2443,2449 ****
if (TYPE_TEMPLATE_INFO (t))
{
tree args = TREE_VALUE (TYPE_TEMPLATE_INFO (t));
! walk_tree (&args, &find_parameter_packs_r, ppd, ppd->visited);
}
*walk_subtrees = 0;
--- 2443,2449 ----
if (TYPE_TEMPLATE_INFO (t))
{
tree args = TREE_VALUE (TYPE_TEMPLATE_INFO (t));
! cp_walk_tree (&args, &find_parameter_packs_r, ppd, ppd->visited);
}
*walk_subtrees = 0;
*************** find_parameter_packs_r (tree *tp, int *w
*** 2463,2470 ****
return NULL_TREE;
case INTEGER_TYPE:
! walk_tree (&TYPE_MAX_VALUE (t), &find_parameter_packs_r,
! ppd, ppd->visited);
*walk_subtrees = 0;
return NULL_TREE;
--- 2463,2470 ----
return NULL_TREE;
case INTEGER_TYPE:
! cp_walk_tree (&TYPE_MAX_VALUE (t), &find_parameter_packs_r,
! ppd, ppd->visited);
*walk_subtrees = 0;
return NULL_TREE;
*************** uses_parameter_packs (tree t)
*** 2486,2492 ****
struct find_parameter_pack_data ppd;
ppd.parameter_packs = ¶meter_packs;
ppd.visited = pointer_set_create ();
! walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
pointer_set_destroy (ppd.visited);
return parameter_packs != NULL_TREE;
}
--- 2486,2492 ----
struct find_parameter_pack_data ppd;
ppd.parameter_packs = ¶meter_packs;
ppd.visited = pointer_set_create ();
! cp_walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
pointer_set_destroy (ppd.visited);
return parameter_packs != NULL_TREE;
}
*************** make_pack_expansion (tree arg)
*** 2536,2543 ****
class expansion. */
ppd.visited = pointer_set_create ();
ppd.parameter_packs = ¶meter_packs;
! walk_tree (&TREE_PURPOSE (arg), &find_parameter_packs_r,
! &ppd, ppd.visited);
if (parameter_packs == NULL_TREE)
{
--- 2536,2543 ----
class expansion. */
ppd.visited = pointer_set_create ();
ppd.parameter_packs = ¶meter_packs;
! cp_walk_tree (&TREE_PURPOSE (arg), &find_parameter_packs_r,
! &ppd, ppd.visited);
if (parameter_packs == NULL_TREE)
{
*************** make_pack_expansion (tree arg)
*** 2554,2561 ****
{
/* Determine which parameter packs will be expanded in this
argument. */
! walk_tree (&TREE_VALUE (value), &find_parameter_packs_r,
! &ppd, ppd.visited);
}
}
--- 2554,2561 ----
{
/* Determine which parameter packs will be expanded in this
argument. */
! cp_walk_tree (&TREE_VALUE (value), &find_parameter_packs_r,
! &ppd, ppd.visited);
}
}
*************** make_pack_expansion (tree arg)
*** 2593,2599 ****
/* Determine which parameter packs will be expanded. */
ppd.parameter_packs = ¶meter_packs;
ppd.visited = pointer_set_create ();
! walk_tree (&arg, &find_parameter_packs_r, &ppd, ppd.visited);
pointer_set_destroy (ppd.visited);
/* Make sure we found some parameter packs. */
--- 2593,2599 ----
/* Determine which parameter packs will be expanded. */
ppd.parameter_packs = ¶meter_packs;
ppd.visited = pointer_set_create ();
! cp_walk_tree (&arg, &find_parameter_packs_r, &ppd, ppd.visited);
pointer_set_destroy (ppd.visited);
/* Make sure we found some parameter packs. */
*************** check_for_bare_parameter_packs (tree t)
*** 2638,2644 ****
ppd.parameter_packs = ¶meter_packs;
ppd.visited = pointer_set_create ();
! walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
pointer_set_destroy (ppd.visited);
if (parameter_packs)
--- 2638,2644 ----
ppd.parameter_packs = ¶meter_packs;
ppd.visited = pointer_set_create ();
! cp_walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
pointer_set_destroy (ppd.visited);
if (parameter_packs)
*************** for_each_template_parm (tree t, tree_fn_
*** 5895,5904 ****
pfd.visited = visited;
else
pfd.visited = pointer_set_create ();
! result = walk_tree (&t,
! for_each_template_parm_r,
! &pfd,
! pfd.visited) != NULL_TREE;
/* Clean up. */
if (!visited)
--- 5895,5904 ----
pfd.visited = visited;
else
pfd.visited = pointer_set_create ();
! result = cp_walk_tree (&t,
! for_each_template_parm_r,
! &pfd,
! pfd.visited) != NULL_TREE;
/* Clean up. */
if (!visited)
Index: cp/semantics.c
===================================================================
*** cp/semantics.c (revision 126953)
--- cp/semantics.c (working copy)
*************** expand_or_defer_fn (tree fn)
*** 3179,3187 ****
}
/* Replace AGGR_INIT_EXPRs with appropriate CALL_EXPRs. */
! walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),
! simplify_aggr_init_exprs_r,
! NULL);
/* If this is a constructor or destructor body, we have to clone
it. */
--- 3179,3187 ----
}
/* Replace AGGR_INIT_EXPRs with appropriate CALL_EXPRs. */
! cp_walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),
! simplify_aggr_init_exprs_r,
! NULL);
/* If this is a constructor or destructor body, we have to clone
it. */
*************** finalize_nrv (tree *tp, tree var, tree r
*** 3331,3337 ****
data.var = var;
data.result = result;
data.visited = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
! walk_tree (tp, finalize_nrv_r, &data, 0);
htab_delete (data.visited);
}
\f
--- 3331,3337 ----
data.var = var;
data.result = result;
data.visited = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
! cp_walk_tree (tp, finalize_nrv_r, &data, 0);
htab_delete (data.visited);
}
\f
Index: cp/decl2.c
===================================================================
*** cp/decl2.c (revision 126953)
--- cp/decl2.c (working copy)
*************** static int
*** 1569,1575 ****
type_visibility (tree type)
{
int vis = VISIBILITY_DEFAULT;
! walk_tree_without_duplicates (&type, min_vis_r, &vis);
return vis;
}
--- 1569,1575 ----
type_visibility (tree type)
{
int vis = VISIBILITY_DEFAULT;
! cp_walk_tree_without_duplicates (&type, min_vis_r, &vis);
return vis;
}
Index: langhooks.c
===================================================================
*** langhooks.c (revision 126953)
--- langhooks.c (working copy)
*************** lhd_types_compatible_p (tree x, tree y)
*** 268,294 ****
return TYPE_MAIN_VARIANT (x) == TYPE_MAIN_VARIANT (y);
}
- /* lang_hooks.tree_inlining.walk_subtrees is called by walk_tree()
- after handling common cases, but before walking code-specific
- sub-trees. If this hook is overridden for a language, it should
- handle language-specific tree codes, as well as language-specific
- information associated to common tree codes. If a tree node is
- completely handled within this function, it should set *SUBTREES to
- 0, so that generic handling isn't attempted. The generic handling
- cannot deal with language-specific tree codes, so make sure it is
- set properly. Both SUBTREES and *SUBTREES is guaranteed to be
- nonzero when the function is called. */
-
- tree
- lhd_tree_inlining_walk_subtrees (tree *tp ATTRIBUTE_UNUSED,
- int *subtrees ATTRIBUTE_UNUSED,
- walk_tree_fn func ATTRIBUTE_UNUSED,
- void *data ATTRIBUTE_UNUSED,
- struct pointer_set_t *pset ATTRIBUTE_UNUSED)
- {
- return NULL_TREE;
- }
-
/* lang_hooks.tree_inlining.cannot_inline_tree_fn is called to
determine whether there are language-specific reasons for not
inlining a given function. */
--- 268,273 ----
Index: langhooks.h
===================================================================
*** langhooks.h (revision 126953)
--- langhooks.h (working copy)
*************** typedef void (*lang_print_tree_hook) (FI
*** 35,43 ****
struct lang_hooks_for_tree_inlining
{
- tree (*walk_subtrees) (tree *, int *,
- tree (*) (tree *, int *, void *),
- void *, struct pointer_set_t*);
int (*cannot_inline_tree_fn) (tree *);
int (*disregard_inline_limits) (tree);
int (*auto_var_in_fn_p) (tree, tree);
--- 35,40 ----
Index: langhooks-def.h
===================================================================
*** langhooks-def.h (revision 126953)
--- langhooks-def.h (working copy)
*************** extern tree lhd_expr_to_decl (tree, bool
*** 67,74 ****
extern tree lhd_builtin_function (tree decl);
/* Declarations of default tree inlining hooks. */
- extern tree lhd_tree_inlining_walk_subtrees (tree *, int *, walk_tree_fn,
- void *, struct pointer_set_t*);
extern int lhd_tree_inlining_cannot_inline_tree_fn (tree *);
extern int lhd_tree_inlining_disregard_inline_limits (tree);
extern int lhd_tree_inlining_auto_var_in_fn_p (tree, tree);
--- 67,72 ----
*************** extern void lhd_omp_firstprivatize_type_
*** 134,140 ****
#define LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE NULL
/* Tree inlining hooks. */
- #define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES lhd_tree_inlining_walk_subtrees
#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
lhd_tree_inlining_cannot_inline_tree_fn
#define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \
--- 132,137 ----
*************** extern void lhd_omp_firstprivatize_type_
*** 145,151 ****
hook_bool_tree_tree_false
#define LANG_HOOKS_TREE_INLINING_INITIALIZER { \
- LANG_HOOKS_TREE_INLINING_WALK_SUBTREES, \
LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN, \
LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS, \
LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P, \
--- 142,147 ----
Index: java/lang.c
===================================================================
*** java/lang.c (revision 126953)
--- java/lang.c (working copy)
*************** static int java_handle_option (size_t sc
*** 56,63 ****
static void put_decl_string (const char *, int);
static void put_decl_node (tree);
static void java_print_error_function (diagnostic_context *, const char *);
- static tree java_tree_inlining_walk_subtrees (tree *, int *, walk_tree_fn,
- void *, struct pointer_set_t *);
static int merge_init_test_initialization (void * *, void *);
static int inline_init_test_initialization (void * *, void *);
static bool java_dump_tree (void *, tree);
--- 56,61 ----
*************** struct language_function GTY(())
*** 189,197 ****
#undef LANG_HOOKS_GIMPLIFY_EXPR
#define LANG_HOOKS_GIMPLIFY_EXPR java_gimplify_expr
- #undef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES
- #define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES java_tree_inlining_walk_subtrees
-
#undef LANG_HOOKS_DECL_OK_FOR_SIBCALL
#define LANG_HOOKS_DECL_OK_FOR_SIBCALL java_decl_ok_for_sibcall
--- 187,192 ----
*************** decl_constant_value (tree decl)
*** 689,737 ****
return decl;
}
- /* Walk the language specific tree nodes during inlining. */
-
- static tree
- java_tree_inlining_walk_subtrees (tree *tp ATTRIBUTE_UNUSED,
- int *subtrees ATTRIBUTE_UNUSED,
- walk_tree_fn func ATTRIBUTE_UNUSED,
- void *data ATTRIBUTE_UNUSED,
- struct pointer_set_t *pset ATTRIBUTE_UNUSED)
- {
- enum tree_code code;
- tree result;
-
- #define WALK_SUBTREE(NODE) \
- do \
- { \
- result = walk_tree (&(NODE), func, data, pset); \
- if (result) \
- return result; \
- } \
- while (0)
-
- tree t = *tp;
- if (!t)
- return NULL_TREE;
-
- code = TREE_CODE (t);
- switch (code)
- {
- case BLOCK:
- WALK_SUBTREE (BLOCK_EXPR_BODY (t));
- return NULL_TREE;
-
- case EXIT_BLOCK_EXPR:
- *subtrees = 0;
- return NULL_TREE;
-
- default:
- return NULL_TREE;
- }
-
- #undef WALK_SUBTREE
- }
-
/* Every call to a static constructor has an associated boolean
variable which is in the outermost scope of the calling method.
This variable is used to avoid multiple calls to the static
--- 684,689 ----
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][C++/Java] Get rid of the walk_subtrees langhook
2007-07-26 14:32 [PATCH][C++/Java] Get rid of the walk_subtrees langhook Richard Guenther
@ 2007-07-26 16:35 ` Andrew Haley
2007-08-06 0:24 ` Mark Mitchell
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Haley @ 2007-07-26 16:35 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
Richard Guenther writes:
>
> This gets rid of the walk_subtrees langhook which is called at every
> invocation of walk_trees. The only real user is the C++ frontend which
> is too lazy to use its own walk_tree. Instead of duplicating walk_tree
> there I made the langhook an extra callback parameter for walk_tree
> and replaced all occurances in the C++ frontend by a wrapper called
> cp_walk_tree that passes the current langhook implementation. All
> cases covered in the langhook look frontend specific and should not
> affect middle-end walkers.
>
> Apart from nice to LTO this should bring a noticable speedup for
> targets with slow indirect calls.
>
> Full bootstrap and regtest on x86_64-unknown-linux-gnu still running
> for C++ and Java, though build and C++ testing finished successfully
> already.
>
> Ok for mainline? (This needs a GWP at best)
>
> Note I did not go through callers to walk_tree in the C++ frontend
> to identify which ones really need the callback but just changed them
> all over.
I guess that's OK, yes. Now that inlining is done on generic trees
rather than java FE trees there's no need for java_tree_inlining_walk_subtrees.
Andrew.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][C++/Java] Get rid of the walk_subtrees langhook
2007-07-26 14:32 [PATCH][C++/Java] Get rid of the walk_subtrees langhook Richard Guenther
2007-07-26 16:35 ` Andrew Haley
@ 2007-08-06 0:24 ` Mark Mitchell
2007-08-20 11:18 ` Richard Guenther
1 sibling, 1 reply; 4+ messages in thread
From: Mark Mitchell @ 2007-08-06 0:24 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
Richard Guenther wrote:
> 2007-07-26 Richard Guenther <rguenther@suse.de>
>
> * tree.c (WALK_SUBTREE): Call walk_tree_1.
> (walk_type_fields): Take lh parameter.
This is OK, with one change: I don't think "walk_tree_lh" is a mnemonic
name for the type of the supplemental walker function. Perhaps
"walk_subtree_fn", like "walk_tree_fn", is better. In any case, the
typedef should have a comment saying what the varios parameters are.
With those changes, the patch is fine, thanks!
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][C++/Java] Get rid of the walk_subtrees langhook
2007-08-06 0:24 ` Mark Mitchell
@ 2007-08-20 11:18 ` Richard Guenther
0 siblings, 0 replies; 4+ messages in thread
From: Richard Guenther @ 2007-08-20 11:18 UTC (permalink / raw)
To: Mark Mitchell; +Cc: gcc-patches
On Sun, 5 Aug 2007, Mark Mitchell wrote:
> Richard Guenther wrote:
>
> > 2007-07-26 Richard Guenther <rguenther@suse.de>
> >
> > * tree.c (WALK_SUBTREE): Call walk_tree_1.
> > (walk_type_fields): Take lh parameter.
>
> This is OK, with one change: I don't think "walk_tree_lh" is a mnemonic
> name for the type of the supplemental walker function. Perhaps
> "walk_subtree_fn", like "walk_tree_fn", is better. In any case, the
> typedef should have a comment saying what the varios parameters are.
walk_subtree_fn isn't any better I think (walk_tree_lh was supposed to
mean _langhook ;)). The walk_tree_lh function has the same signature
as the (old) walk_tree function, so walk_tree_fn would be a match, but
that is already used... Initially I didn't expose the signature with
a typedef, but writing the long prototype everywhere isn't any better.
I added a comment before the typedef and left the name in place
(I volunteer to change it to sth else if anyone has a good idea as
a followup).
> With those changes, the patch is fine, thanks!
Thanks,
Richard.
--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-20 11:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 14:32 [PATCH][C++/Java] Get rid of the walk_subtrees langhook Richard Guenther
2007-07-26 16:35 ` Andrew Haley
2007-08-06 0:24 ` Mark Mitchell
2007-08-20 11:18 ` Richard Guenther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).