gimple-low.c (expand_var_p): Don't look at TREE_ADDRESSABLE...

* gimple-low.c (expand_var_p): Don't look at TREE_ADDRESSABLE,
        TREE_THIS_VOLATILE, may_aliases, or optimization level.
        (remove_useless_vars): Dump debugging info.
        (expand_used_vars): Move ...
        * cfgexpand.c (expand_used_vars): ... here.  Make static.
        * tree-flow-inline.h (set_is_used): New.
        (set_default_def): Use get_var_ann.
        * tree-flow.h: Update decls.
        * tree-ssa-live.c (mark_all_vars_used_1, mark_all_vars_used): New.
        (create_ssa_var_map): Use it.
        * tree-ssa.c (set_is_used): Remove.

From-SVN: r85034
This commit is contained in:
Richard Henderson 2004-07-21 19:48:27 -07:00 committed by Richard Henderson
parent eecbcf5428
commit 727a31fab8
7 changed files with 97 additions and 60 deletions

View File

@ -1,3 +1,17 @@
2004-07-21 Richard Henderson <rth@redhat.com>
* gimple-low.c (expand_var_p): Don't look at TREE_ADDRESSABLE,
TREE_THIS_VOLATILE, may_aliases, or optimization level.
(remove_useless_vars): Dump debugging info.
(expand_used_vars): Move ...
* cfgexpand.c (expand_used_vars): ... here. Make static.
* tree-flow-inline.h (set_is_used): New.
(set_default_def): Use get_var_ann.
* tree-flow.h: Update decls.
* tree-ssa-live.c (mark_all_vars_used_1, mark_all_vars_used): New.
(create_ssa_var_map): Use it.
* tree-ssa.c (set_is_used): Remove.
2004-07-22 Ben Elliston <bje@au.ibm.com>
* gdbinit.in: Set a breakpoint on internal_error.

View File

@ -37,6 +37,22 @@ Boston, MA 02111-1307, USA. */
#include "flags.h"
/* Expand variables in the unexpanded_var_list. */
static void
expand_used_vars (void)
{
tree cell;
cfun->unexpanded_var_list = nreverse (cfun->unexpanded_var_list);
for (cell = cfun->unexpanded_var_list; cell; cell = TREE_CHAIN (cell))
expand_var (TREE_VALUE (cell));
cfun->unexpanded_var_list = NULL_TREE;
}
/* A subroutine of expand_gimple_basic_block. Expand one COND_EXPR.
Returns a new basic block if we've terminated the current basic
block and created a new one. */
@ -420,10 +436,7 @@ tree_expand_cfg (void)
/* Prepare the rtl middle end to start recording block changes. */
reset_block_changes ();
/* Expand the variables recorded during gimple lowering. This must
occur before the call to expand_function_start to ensure that
all used variables are expanded before we expand anything on the
PENDING_SIZES list. */
/* Expand the variables recorded during gimple lowering. */
expand_used_vars ();
/* Set up parameters and prepare for return, for the function. */

View File

@ -475,15 +475,13 @@ expand_var_p (tree var)
if (TREE_CODE (var) != VAR_DECL)
return true;
/* Remove all unused, unaliased temporaries. Also remove unused, unaliased
local variables during highly optimizing compilations. */
/* Leave statics and externals alone. */
if (TREE_STATIC (var) || DECL_EXTERNAL (var))
return true;
/* Remove all unused local variables. */
ann = var_ann (var);
if (ann
&& ! ann->may_aliases
&& ! ann->used
&& ! TREE_ADDRESSABLE (var)
&& ! TREE_THIS_VOLATILE (var)
&& (DECL_ARTIFICIAL (var) || optimize >= 2))
if (!ann || !ann->used)
return false;
return true;
@ -495,6 +493,13 @@ static void
remove_useless_vars (void)
{
tree var, *cell;
FILE *df = NULL;
if (dump_file && (dump_flags & TDF_DETAILS))
{
df = dump_file;
fputs ("Discarding as unused:\n", df);
}
for (cell = &cfun->unexpanded_var_list; *cell; )
{
@ -502,27 +507,22 @@ remove_useless_vars (void)
if (!expand_var_p (var))
{
if (df)
{
fputs (" ", df);
print_generic_expr (df, var, dump_flags);
fputc ('\n', df);
}
*cell = TREE_CHAIN (*cell);
continue;
}
cell = &TREE_CHAIN (*cell);
}
}
/* Expand variables in the unexpanded_var_list. */
void
expand_used_vars (void)
{
tree cell;
cfun->unexpanded_var_list = nreverse (cfun->unexpanded_var_list);
for (cell = cfun->unexpanded_var_list; cell; cell = TREE_CHAIN (cell))
expand_var (TREE_VALUE (cell));
cfun->unexpanded_var_list = NULL_TREE;
if (df)
fputc ('\n', df);
}
struct tree_opt_pass pass_remove_useless_vars =

View File

@ -421,6 +421,16 @@ phi_arg_from_edge (tree phi, edge e)
return -1;
}
/* Mark VAR as used, so that it'll be preserved during rtl expansion. */
static inline void
set_is_used (tree var)
{
var_ann_t ann = get_var_ann (var);
ann->used = 1;
}
/* ----------------------------------------------------------------------- */
/* Return true if T is an executable statement. */
@ -453,9 +463,7 @@ is_label_stmt (tree t)
static inline void
set_default_def (tree var, tree def)
{
var_ann_t ann = var_ann (var);
if (ann == NULL)
ann = create_var_ann (var);
var_ann_t ann = get_var_ann (var);
ann->default_def = def;
}

View File

@ -535,7 +535,6 @@ extern tree make_rename_temp (tree, const char *);
/* In gimple-low.c */
struct lower_data;
extern void lower_stmt_body (tree, struct lower_data *);
extern void expand_used_vars (void);
extern void record_vars (tree);
extern bool block_may_fallthru (tree block);
@ -565,7 +564,6 @@ extern void dump_tree_ssa_stats (FILE *);
extern void debug_tree_ssa_stats (void);
extern void ssa_remove_edge (edge);
extern edge ssa_redirect_edge (edge, basic_block);
extern void set_is_used (tree);
extern bool tree_ssa_useless_type_conversion (tree);
extern bool tree_ssa_useless_type_conversion_1 (tree, tree);
extern void verify_ssa (void);
@ -647,6 +645,7 @@ bool for_each_index (tree *, bool (*) (tree, tree *, void *), void *);
static inline int phi_arg_from_edge (tree, edge);
static inline bool is_call_clobbered (tree);
static inline void mark_call_clobbered (tree);
static inline void set_is_used (tree);
/* In tree-eh.c */
extern void make_eh_edges (tree);

View File

@ -285,6 +285,34 @@ change_partition_var (var_map map, tree var, int part)
}
/* Helper function for mark_all_vars_used, called via walk_tree. */
static tree
mark_all_vars_used_1 (tree *tp, int *walk_subtrees,
void *data ATTRIBUTE_UNUSED)
{
tree t = *tp;
/* Only need to mark VAR_DECLS; parameters and return results are not
eliminated as unused. */
if (TREE_CODE (t) == VAR_DECL)
set_is_used (t);
if (DECL_P (t) || TYPE_P (t))
*walk_subtrees = 0;
return NULL;
}
/* Mark all VAR_DECLS under *EXPR_P as used, so that they won't be
eliminated during the tree->rtl conversion process. */
static inline void
mark_all_vars_used (tree *expr_p)
{
walk_tree (expr_p, mark_all_vars_used_1, NULL, NULL);
}
/* This function looks through the program and uses FLAGS to determine what
SSA versioned variables are given entries in a new partition table. This
new partition map is returned. */
@ -338,6 +366,8 @@ create_ssa_var_map (int flags)
arg = PHI_ARG_DEF (phi, i);
if (TREE_CODE (arg) == SSA_NAME)
register_ssa_partition (map, arg, true);
mark_all_vars_used (&PHI_ARG_DEF_TREE (phi, i));
}
}
@ -377,8 +407,6 @@ create_ssa_var_map (int flags)
for (x = 0; x < NUM_VUSES (vuses); x++)
{
tree var = VUSE_OP (vuses, x);
set_is_used (var);
#if defined ENABLE_CHECKING
SET_BIT (used_in_virtual_ops, var_ann (SSA_NAME_VAR (var))->uid);
#endif
@ -388,8 +416,6 @@ create_ssa_var_map (int flags)
for (x = 0; x < NUM_V_MAY_DEFS (v_may_defs); x++)
{
tree var = V_MAY_DEF_OP (v_may_defs, x);
set_is_used (var);
#if defined ENABLE_CHECKING
SET_BIT (used_in_virtual_ops, var_ann (SSA_NAME_VAR (var))->uid);
#endif
@ -399,11 +425,12 @@ create_ssa_var_map (int flags)
for (x = 0; x < NUM_V_MUST_DEFS (v_must_defs); x++)
{
tree var = V_MUST_DEF_OP (v_must_defs, x);
set_is_used (var);
#if defined ENABLE_CHECKING
SET_BIT (used_in_virtual_ops, var_ann (SSA_NAME_VAR (var))->uid);
#endif
}
mark_all_vars_used (bsi_stmt_ptr (bsi));
}
}

View File

@ -463,30 +463,6 @@ verify_ssa (void)
}
/* Set the USED bit in the annotation for T. */
void
set_is_used (tree t)
{
while (1)
{
if (SSA_VAR_P (t))
break;
if (TREE_CODE (t) == REALPART_EXPR || TREE_CODE (t) == IMAGPART_EXPR)
t = TREE_OPERAND (t, 0);
else
while (handled_component_p (t))
t = TREE_OPERAND (t, 0);
}
if (TREE_CODE (t) == SSA_NAME)
t = SSA_NAME_VAR (t);
var_ann (t)->used = 1;
}
/* Initialize global DFA and SSA structures. */
void