+2008-05-16 Kenneth Zadeck <zadeck@naturalbridge.com>
+
+ * tree-ssa-dse (max_stmt_uid): Removed.
+ (get_stmt_uid, dse_possible_dead_store_p, dse_optimize_stmt,
+ tree_ssa_dse): Encapsulate all uses of stmt_ann->uid.
+ * tree-ssa-sccvn.c (compare_ops, init_scc_vn): Ditto.
+ * function.h (cfun.last_stmt_uid): New field.
+ * tree-flow-inline.h (set_gimple_stmt_uid, gimple_stmt_uid,
+ gimple_stmt_max_uid, set_gimple_stmt_max_uid,
+ inc_gimple_stmt_max_uid): New functions.
+ * tree-dfa.c (renumber_gimple_stmt_uids): New function.
+ (create_stmt_ann): Initialize the ann->uid field.
+ * tree-ssa-pre.c (compute_avail): Encapsulate the stmt_ann->uid
+ with new calls.
+ * tree-flow.h (renumber_gimple_stmt_uids): New function.
+
2008-05-16 Nathan Froyd <froydnj@codesourcery.com>
* tree-flow.h (init_empty_tree_cfg_for_function): Declare.
* config/bfin/bfin.c (bfin_discover_loops): Delete empty loops.
From Jie Zhang <jie.zhang@analog.com>
- * config/bfin/t-bfin-elf (MULTILIB_OPTIONS, MULTILIB_DIRNAMES,
+ * config/bfin/t-bfin-elf (MULTILIB_OPTIONS, MULTILIB_DIRNAMES,
MULTILIB_MATCHES, MULTILIB_EXCEPTIONS): Remove mcpu=bf532-0.3,
mcpu=bf561-none and mcpu=bf561-0.2.
* config/bfin/t-bfin-uclinux (MULTILIB_OPTIONS, MULTILIB_DIRNAMES,
/* Used types hash table. */
htab_t GTY ((param_is (union tree_node))) used_types_hash;
+ /* Last statement uid. */
+ int last_stmt_uid;
+
/* Line number of the end of the function. */
location_t function_end_locus;
{
basic_block bb;
block_stmt_iterator si;
+ tree phi;
FOR_EACH_BB (bb)
- for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
- {
- tree *stmt_p = bsi_stmt_ptr (si);
- walk_tree (stmt_p, find_vars_r, NULL, NULL);
- }
+ {
+ for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
+ {
+ tree *stmt_p = bsi_stmt_ptr (si);
+ walk_tree (stmt_p, find_vars_r, NULL, NULL);
+ }
+
+ for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
+ {
+ int len = PHI_NUM_ARGS (phi);
+ int i;
+
+ walk_tree (&phi, find_vars_r, NULL, NULL);
+
+ for (i = 0; i < len; i++)
+ {
+ tree arg = PHI_ARG_DEF (phi, i);
+ walk_tree (&arg, find_vars_r, NULL, NULL);
+ }
+ }
+ }
return 0;
}
PROP_gimple_leh | PROP_cfg, /* properties_required */
PROP_referenced_vars, /* properties_provided */
0, /* properties_destroyed */
- 0, /* todo_flags_start */
- 0 /* todo_flags_finish */
+ TODO_dump_func, /* todo_flags_start */
+ TODO_dump_func /* todo_flags_finish */
}
};
/* Since we just created the annotation, mark the statement modified. */
ann->modified = true;
+ ann->uid = inc_gimple_stmt_max_uid (cfun);
t->base.ann = (tree_ann_t) ann;
return ann;
}
+/* Renumber all of the gimple stmt uids. */
+
+void
+renumber_gimple_stmt_uids (void)
+{
+ basic_block bb;
+
+ set_gimple_stmt_max_uid (cfun, 0);
+ FOR_ALL_BB (bb)
+ {
+ block_stmt_iterator bsi;
+ for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
+ {
+ tree stmt = bsi_stmt (bsi);
+ /* If the stmt has an annotation, then overwrite it, if not,
+ the process of getting it will set the number
+ properly. */
+ if (has_stmt_ann (stmt))
+ set_gimple_stmt_uid (stmt, inc_gimple_stmt_max_uid (cfun));
+ else
+ get_stmt_ann (stmt);
+ }
+ }
+}
+
/* Create a new annotation for a tree T. */
tree_ann_common_t
static tree
find_vars_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
{
+ /* If we are reading the lto info back in, we need to rescan the
+ referenced vars. */
+ if (TREE_CODE (*tp) == SSA_NAME)
+ add_referenced_var (SSA_NAME_VAR (*tp));
+
/* If T is a regular variable that the optimizers are interested
in, add it to the list of variables. */
- if (SSA_VAR_P (*tp))
+ else if (SSA_VAR_P (*tp))
add_referenced_var (*tp);
/* Type, _DECL and constant nodes have no interesting children.
return (ann) ? ann : create_stmt_ann (stmt);
}
+/* Set the uid of all non phi function statements. */
+static inline void
+set_gimple_stmt_uid (tree stmt, unsigned int uid)
+{
+ get_stmt_ann (stmt)->uid = uid;
+}
+
+/* Get the uid of all non phi function statements. */
+static inline unsigned int
+gimple_stmt_uid (tree stmt)
+{
+ return get_stmt_ann (stmt)->uid;
+}
+
+/* Get the number of the next statement uid to be allocated. */
+static inline unsigned int
+gimple_stmt_max_uid (struct function *fn)
+{
+ return fn->last_stmt_uid;
+}
+
+/* Set the number of the next statement uid to be allocated. */
+static inline void
+set_gimple_stmt_max_uid (struct function *fn, unsigned int maxid)
+{
+ fn->last_stmt_uid = maxid;
+}
+
+/* Set the number of the next statement uid to be allocated. */
+static inline unsigned int
+inc_gimple_stmt_max_uid (struct function *fn)
+{
+ return fn->last_stmt_uid++;
+}
+
/* Return the annotation type for annotation ANN. */
static inline enum tree_ann_type
ann_type (tree_ann_t ann)
/* Set of variables that have had their address taken in the statement. */
bitmap addresses_taken;
- /* Unique identifier for this statement. These ID's are to be created
- by each pass on an as-needed basis in any order convenient for the
- pass which needs statement UIDs. */
+ /* Unique identifier for this statement. These ID's are to be
+ created by each pass on an as-needed basis in any order
+ convenient for the pass which needs statement UIDs. This field
+ should only be accessed thru set_gimple_stmt_uid and
+ gimple_stmt_uid functions. */
unsigned int uid;
/* Nonzero if the statement references memory (at least one of its
extern tree gimplify_build3 (block_stmt_iterator *, enum tree_code,
tree, tree, tree, tree);
extern void init_empty_tree_cfg (void);
+extern void init_empty_tree_cfg_for_function (struct function *);
extern void fold_cond_expr_cond (void);
extern void make_abnormal_goto_edges (basic_block, bool);
extern void replace_uses_by (tree, tree);
extern var_ann_t create_var_ann (tree);
extern function_ann_t create_function_ann (tree);
extern stmt_ann_t create_stmt_ann (tree);
+extern void renumber_gimple_stmt_uids (void);
extern tree_ann_common_t create_tree_common_ann (tree);
extern void dump_dfa_stats (FILE *);
extern void debug_dfa_stats (void);
/* A vector of var maps. */
typedef VEC(edge_var_map, heap) *edge_var_map_vector;
+extern void init_tree_ssa (struct function *);
extern void redirect_edge_var_map_add (edge, tree, tree);
extern void redirect_edge_var_map_clear (edge);
extern void redirect_edge_var_map_dup (edge, edge);
extern edge_var_map_vector redirect_edge_var_map_vector (edge);
extern void redirect_edge_var_map_destroy (void);
-extern void init_tree_ssa (struct function *);
extern edge ssa_redirect_edge (edge, basic_block);
extern void flush_pending_stmts (edge);
extern bool tree_ssa_useless_type_conversion (tree);
static void dse_finalize_block (struct dom_walk_data *, basic_block);
static void record_voperand_set (bitmap, bitmap *, unsigned int);
-static unsigned max_stmt_uid; /* Maximal uid of a statement. Uids to phi
- nodes are assigned using the versions of
- ssa names they define. */
-
/* Returns uid of statement STMT. */
static unsigned
get_stmt_uid (tree stmt)
{
if (TREE_CODE (stmt) == PHI_NODE)
- return SSA_NAME_VERSION (PHI_RESULT (stmt)) + max_stmt_uid;
+ return SSA_NAME_VERSION (PHI_RESULT (stmt)) + gimple_stmt_max_uid (cfun);
- return stmt_ann (stmt)->uid;
+ return gimple_stmt_uid (stmt);
}
/* Set bit UID in bitmaps GLOBAL and *LOCAL, creating *LOCAL as needed. */
vuse_vec_p vv;
tree defvar = NULL_TREE, temp;
tree prev_defvar = NULL_TREE;
- stmt_ann_t ann = stmt_ann (stmt);
/* We want to verify that each virtual definition in STMT has
precisely one use and that all the virtual definitions are
if (fail)
{
- record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
+ record_voperand_set (dse_gd->stores, &bd->stores, gimple_stmt_uid (stmt));
return false;
}
memory location. */
if (!get_kill_of_stmt_lhs (stmt, &first_use_p, &use_p, &use_stmt))
{
- record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
+ record_voperand_set (dse_gd->stores, &bd->stores, gimple_stmt_uid (stmt));
return;
}
}
release_defs (stmt);
}
- record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
+ record_voperand_set (dse_gd->stores, &bd->stores, gimple_stmt_uid (stmt));
}
}
{
struct dom_walk_data walk_data;
struct dse_global_data dse_gd;
- basic_block bb;
- /* Create a UID for each statement in the function. Ordering of the
- UIDs is not important for this pass. */
- max_stmt_uid = 0;
- FOR_EACH_BB (bb)
- {
- block_stmt_iterator bsi;
-
- for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
- stmt_ann (bsi_stmt (bsi))->uid = max_stmt_uid++;
- }
+ renumber_gimple_stmt_uids ();
/* We might consider making this a property of each pass so that it
can be [re]computed on an as-needed basis. Particularly since
new_tree = build_gimple_modify_stmt (NULL_TREE, lhs);
new_lhs = make_ssa_name (storetemp, new_tree);
GIMPLE_STMT_OPERAND (new_tree, 0) = new_lhs;
-
create_ssa_artificial_load_stmt (new_tree, stmt, false);
NECESSARY (new_tree) = 0;
stmt = bsi_stmt (bsi);
ann = stmt_ann (stmt);
- ann->uid = stmt_uid++;
+ set_gimple_stmt_uid (stmt, stmt_uid++);
/* For regular value numbering, we are only interested in
assignments of the form X_i = EXPR, where EXPR represents
return -1;
else if (TREE_CODE (opstmtb) == PHI_NODE)
return 1;
- return stmt_ann (opstmta)->uid - stmt_ann (opstmtb)->uid;
+ return gimple_stmt_uid (opstmta) - gimple_stmt_uid (opstmtb);
}
return rpo_numbers[bba->index] - rpo_numbers[bbb->index];
}
size_t i;
int j;
int *rpo_numbers_temp;
- basic_block bb;
- size_t id = 0;
calculate_dominance_info (CDI_DOMINATORS);
sccstack = NULL;
}
}
- FOR_ALL_BB (bb)
- {
- block_stmt_iterator bsi;
- for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
- {
- tree stmt = bsi_stmt (bsi);
- stmt_ann (stmt)->uid = id++;
- }
- }
+ renumber_gimple_stmt_uids ();
/* Create the valid and optimistic value numbering tables. */
valid_info = XCNEW (struct vn_tables_s);