This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][C++] Remove auto_var_in_fn langhook
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 26 Jul 2007 18:17:56 +0200 (CEST)
- Subject: [PATCH][C++] Remove auto_var_in_fn langhook
The langhook is currently only overridden by the C++ frontend but its
implementation doesn't add value over the generic implementation (I
believe after careful looking).
Full bootstrap and regtest still running but the patch has survived
a build and C++ regtest already.
Ok for mainline?
Thanks,
Richard.
2007-07-26 Richard Guenther <rguenther@suse.de>
* langhooks-def.h (lhd_tree_inlining_auto_var_in_fn_p): Remove.
(LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P): Likewise.
(LANG_HOOKS_TREE_INLINING_INITIALIZER): Remove initializer for
auto_var_in_fn_p langhook.
* langhooks.c (lhd_tree_inlining_auto_var_in_fn_p): Rename and
move ...
* tree.c (auto_var_in_fn_p): ... here.
(find_var_from_fn): Call auto_var_in_fn_p directly.
* langhooks.h (lang_hooks_for_tree_inlining): Remove
auto_var_in_fn_p langhook.
* tree-inline.c (remap_decls): Call auto_var_in_fn_p directly.
(copy_body_r): Likewise.
(self_inlining_addr_expr): Likewise.
* tree.h (auto_var_in_fn_p): Declare.
cp/
* cp-objcp-common.h (LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P):
Remove.
* cp-tree.h (cp_auto_var_in_fn_p): Remove.
* tree.c (cp_auto_var_in_fn_p): Remove.
Index: gcc/cp/cp-objcp-common.h
===================================================================
*** gcc.orig/cp/cp-objcp-common.h 2007-07-26 17:19:36.000000000 +0200
--- gcc/cp/cp-objcp-common.h 2007-07-26 17:25:02.000000000 +0200
*************** extern tree objcp_tsubst_copy_and_build
*** 108,116 ****
#undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
cp_cannot_inline_tree_fn
- #undef LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P
- #define LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P \
- cp_auto_var_in_fn_p
#undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P
#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P cp_var_mod_type_p
#undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
--- 108,113 ----
Index: gcc/cp/cp-tree.h
===================================================================
*** gcc.orig/cp/cp-tree.h 2007-07-26 17:19:36.000000000 +0200
--- gcc/cp/cp-tree.h 2007-07-26 17:26:32.000000000 +0200
*************** extern tree cp_walk_subtrees (tree*, int
*** 4730,4736 ****
#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);
extern tree rvalue (tree);
extern tree convert_bitfield_to_declared_type (tree);
--- 4730,4735 ----
Index: gcc/cp/tree.c
===================================================================
*** gcc.orig/cp/tree.c 2007-07-26 17:19:36.000000000 +0200
--- gcc/cp/tree.c 2007-07-26 17:24:47.000000000 +0200
*************** cp_cannot_inline_tree_fn (tree* fnp)
*** 2443,2458 ****
return 0;
}
- /* Determine whether VAR is a declaration of an automatic variable in
- function FN. */
-
- int
- cp_auto_var_in_fn_p (tree var, tree fn)
- {
- return (DECL_P (var) && DECL_CONTEXT (var) == fn
- && nonstatic_local_decl_p (var));
- }
-
/* Like save_expr, but for C++. */
tree
--- 2443,2448 ----
Index: gcc/langhooks-def.h
===================================================================
*** gcc.orig/langhooks-def.h 2007-07-26 17:19:36.000000000 +0200
--- gcc/langhooks-def.h 2007-07-26 17:24:12.000000000 +0200
*************** extern tree lhd_builtin_function (tree d
*** 69,75 ****
/* Declarations of default tree inlining hooks. */
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);
extern void lhd_initialize_diagnostics (struct diagnostic_context *);
extern tree lhd_callgraph_analyze_expr (tree *, int *, tree);
--- 69,74 ----
*************** extern void lhd_omp_firstprivatize_type_
*** 136,150 ****
lhd_tree_inlining_cannot_inline_tree_fn
#define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \
lhd_tree_inlining_disregard_inline_limits
- #define LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P \
- lhd_tree_inlining_auto_var_in_fn_p
#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P \
hook_bool_tree_tree_false
#define LANG_HOOKS_TREE_INLINING_INITIALIZER { \
LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN, \
LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS, \
- LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P, \
LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P, \
}
--- 135,146 ----
Index: gcc/langhooks.c
===================================================================
*** gcc.orig/langhooks.c 2007-07-26 17:19:36.000000000 +0200
--- gcc/langhooks.c 2007-07-26 17:21:34.000000000 +0200
*************** lhd_tree_inlining_disregard_inline_limit
*** 295,313 ****
return 0;
}
- /* lang_hooks.tree_inlining.auto_var_in_fn_p is called to determine
- whether VT is an automatic variable defined in function FT. */
-
- int
- lhd_tree_inlining_auto_var_in_fn_p (tree var, tree fn)
- {
- return (DECL_P (var) && DECL_CONTEXT (var) == fn
- && (((TREE_CODE (var) == VAR_DECL || TREE_CODE (var) == PARM_DECL)
- && ! TREE_STATIC (var))
- || TREE_CODE (var) == LABEL_DECL
- || TREE_CODE (var) == RESULT_DECL));
- }
-
/* lang_hooks.tree_dump.dump_tree: Dump language-specific parts of tree
nodes. Returns nonzero if it does not want the usual dumping of the
second argument. */
--- 295,300 ----
Index: gcc/langhooks.h
===================================================================
*** gcc.orig/langhooks.h 2007-07-26 17:19:36.000000000 +0200
--- gcc/langhooks.h 2007-07-26 17:23:59.000000000 +0200
*************** struct lang_hooks_for_tree_inlining
*** 37,43 ****
{
int (*cannot_inline_tree_fn) (tree *);
int (*disregard_inline_limits) (tree);
- int (*auto_var_in_fn_p) (tree, tree);
bool (*var_mod_type_p) (tree, tree);
};
--- 37,42 ----
Index: gcc/tree-inline.c
===================================================================
*** gcc.orig/tree-inline.c 2007-07-26 14:13:39.000000000 +0200
--- gcc/tree-inline.c 2007-07-26 17:23:36.000000000 +0200
*************** remap_decls (tree decls, copy_body_data
*** 427,433 ****
/* We can not chain the local static declarations into the unexpanded_var_list
as we can't duplicate them or break one decl rule. Go ahead and link
them into unexpanded_var_list. */
! if (!lang_hooks.tree_inlining.auto_var_in_fn_p (old_var, id->src_fn)
&& !DECL_EXTERNAL (old_var))
{
cfun->unexpanded_var_list = tree_cons (NULL_TREE, old_var,
--- 427,433 ----
/* We can not chain the local static declarations into the unexpanded_var_list
as we can't duplicate them or break one decl rule. Go ahead and link
them into unexpanded_var_list. */
! if (!auto_var_in_fn_p (old_var, id->src_fn)
&& !DECL_EXTERNAL (old_var))
{
cfun->unexpanded_var_list = tree_cons (NULL_TREE, old_var,
*************** copy_body_r (tree *tp, int *walk_subtree
*** 585,591 ****
variables. We don't want to copy static variables; there's only
one of those, no matter how many times we inline the containing
function. Similarly for globals from an outer function. */
! else if (lang_hooks.tree_inlining.auto_var_in_fn_p (*tp, fn))
{
tree new_decl;
--- 585,591 ----
variables. We don't want to copy static variables; there's only
one of those, no matter how many times we inline the containing
function. Similarly for globals from an outer function. */
! else if (auto_var_in_fn_p (*tp, fn))
{
tree new_decl;
*************** copy_body_r (tree *tp, int *walk_subtree
*** 640,647 ****
discarding. */
if (TREE_CODE (*tp) == GIMPLE_MODIFY_STMT
&& GIMPLE_STMT_OPERAND (*tp, 0) == GIMPLE_STMT_OPERAND (*tp, 1)
! && (lang_hooks.tree_inlining.auto_var_in_fn_p
! (GIMPLE_STMT_OPERAND (*tp, 0), fn)))
{
/* Some assignments VAR = VAR; don't generate any rtl code
and thus don't count as variable modification. Avoid
--- 640,646 ----
discarding. */
if (TREE_CODE (*tp) == GIMPLE_MODIFY_STMT
&& GIMPLE_STMT_OPERAND (*tp, 0) == GIMPLE_STMT_OPERAND (*tp, 1)
! && (auto_var_in_fn_p (GIMPLE_STMT_OPERAND (*tp, 0), fn)))
{
/* Some assignments VAR = VAR; don't generate any rtl code
and thus don't count as variable modification. Avoid
*************** self_inlining_addr_expr (tree value, tre
*** 1267,1273 ****
var = get_base_address (TREE_OPERAND (value, 0));
! return var && lang_hooks.tree_inlining.auto_var_in_fn_p (var, fn);
}
static void
--- 1266,1272 ----
var = get_base_address (TREE_OPERAND (value, 0));
! return var && auto_var_in_fn_p (var, fn);
}
static void
Index: gcc/tree.c
===================================================================
*** gcc.orig/tree.c 2007-07-26 17:19:36.000000000 +0200
--- gcc/tree.c 2007-07-26 17:21:32.000000000 +0200
*************** get_type_static_bounds (tree type, mpz_t
*** 6305,6310 ****
--- 6305,6323 ----
}
}
+ /* auto_var_in_fn_p is called to determine whether VAR is an automatic
+ variable defined in function FN. */
+
+ bool
+ auto_var_in_fn_p (tree var, tree fn)
+ {
+ return (DECL_P (var) && DECL_CONTEXT (var) == fn
+ && (((TREE_CODE (var) == VAR_DECL || TREE_CODE (var) == PARM_DECL)
+ && ! TREE_STATIC (var))
+ || TREE_CODE (var) == LABEL_DECL
+ || TREE_CODE (var) == RESULT_DECL));
+ }
+
/* Subprogram of following function. Called by walk_tree.
Return *TP if it is an automatic variable or parameter of the
*************** find_var_from_fn (tree *tp, int *walk_su
*** 6319,6325 ****
*walk_subtrees = 0;
else if (DECL_P (*tp)
! && lang_hooks.tree_inlining.auto_var_in_fn_p (*tp, fn))
return *tp;
return NULL_TREE;
--- 6332,6338 ----
*walk_subtrees = 0;
else if (DECL_P (*tp)
! && auto_var_in_fn_p (*tp, fn))
return *tp;
return NULL_TREE;
Index: gcc/tree.h
===================================================================
*** gcc.orig/tree.h 2007-07-26 17:19:36.000000000 +0200
--- gcc/tree.h 2007-07-26 17:22:51.000000000 +0200
*************** extern bool empty_body_p (tree);
*** 4390,4395 ****
--- 4390,4396 ----
extern tree call_expr_arg (tree, int);
extern tree *call_expr_argp (tree, int);
extern tree call_expr_arglist (tree);
+ extern bool auto_var_in_fn_p (tree, tree);
/* In stmt.c */