* Makefile.in (tree-ssanames.o): Depend on TREE_FLOW_H.
* tree-flow.h (ssa_names, num_ssa_names, ssa_name): Declare.
(highest_ssa_version): Remove.
* tree-outof-ssa.c (new_temp_expr_table): Replace
highest_ssa_version with num_ssa_names.
(dump_replaceable_exprs): Likewise.
(rewrite_vars_out_of_ssa): Likewise.
* tree-ssa-ccp.c (initialize): Likewise
* tree-ssa-copyrename.c (rename_ssa_copies): Likewise.
* tree-ssa-dce.c (tree_dce_init): Likewise.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Likewise.
* tree-ssa-live.c (create_ssa_var_map): Likewise.
(dump_var_map): Likewise.
* tree-ssa.c (verify_ssa): Likewise.
(kill_redundant_phi_nodes): Likewise.
Do not build a local array of SSA_NAMEs. Use the ssa_names table.
* tree-ssanames.c: Include tree-flow.h
(ssa_names): New varray.
(init_ssa_names): Initialize ssa_names.
Reserve the first slot of the ssa_names table.
(make_ssa_name): Push the newly created SSA_NAME into ssa_names.
Assign version numbers using num_ssa_names.
From-SVN: r82950
+2004-06-10 Diego Novillo <dnovillo@redhat.com>
+
+ * Makefile.in (tree-ssanames.o): Depend on TREE_FLOW_H.
+ * tree-flow.h (ssa_names, num_ssa_names, ssa_name): Declare.
+ (highest_ssa_version): Remove.
+ * tree-outof-ssa.c (new_temp_expr_table): Replace
+ highest_ssa_version with num_ssa_names.
+ (dump_replaceable_exprs): Likewise.
+ (rewrite_vars_out_of_ssa): Likewise.
+ * tree-ssa-ccp.c (initialize): Likewise
+ * tree-ssa-copyrename.c (rename_ssa_copies): Likewise.
+ * tree-ssa-dce.c (tree_dce_init): Likewise.
+ * tree-ssa-dom.c (tree_ssa_dominator_optimize): Likewise.
+ * tree-ssa-live.c (create_ssa_var_map): Likewise.
+ (dump_var_map): Likewise.
+ * tree-ssa.c (verify_ssa): Likewise.
+ (kill_redundant_phi_nodes): Likewise.
+ Do not build a local array of SSA_NAMEs. Use the ssa_names table.
+ * tree-ssanames.c: Include tree-flow.h
+ (ssa_names): New varray.
+ (init_ssa_names): Initialize ssa_names.
+ Reserve the first slot of the ssa_names table.
+ (make_ssa_name): Push the newly created SSA_NAME into ssa_names.
+ Assign version numbers using num_ssa_names.
+
2004-06-10 Joseph S. Myers <jsm@polyomino.org.uk>
* doc/sourcebuild.texi (Front End): Add details of more
errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
$(BASIC_BLOCK_H) domwalk.h real.h tree-pass.h flags.h langhooks.h
tree-ssanames.o : tree-ssanames.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
- $(TM_H) $(TREE_H) varray.h $(GGC_H) gt-tree-ssanames.h
+ $(TM_H) $(TREE_H) varray.h $(GGC_H) gt-tree-ssanames.h $(TREE_FLOW_H)
tree-phinodes.o : tree-phinodes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(TREE_H) varray.h $(GGC_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
gt-tree-phinodes.h $(RTL_H)
#define num_referenced_vars VARRAY_ACTIVE_SIZE (referenced_vars)
#define referenced_var(i) VARRAY_TREE (referenced_vars, i)
+/* Array of all SSA_NAMEs used in the function. */
+extern GTY(()) varray_type ssa_names;
+
+#define num_ssa_names VARRAY_ACTIVE_SIZE (ssa_names)
+#define ssa_name(i) VARRAY_TREE (ssa_names, i)
+
/* Artificial variable used to model the effects of function calls. */
extern GTY(()) tree global_var;
/* In tree-into-ssa.c */
extern void rewrite_into_ssa (void);
-extern unsigned int highest_ssa_version;
-
/* In tree-ssa-pre.c */
extern void tree_perform_ssapre (tree, enum tree_dump_index);
t = (temp_expr_table_p) xmalloc (sizeof (struct temp_expr_table_d));
t->map = map;
- t->version_info = xcalloc (highest_ssa_version + 1, sizeof (void *));
+ t->version_info = xcalloc (num_ssa_names + 1, sizeof (void *));
t->partition_dep_list = xcalloc (num_var_partitions (map) + 1,
sizeof (value_expr_p));
tree stmt, var;
int x;
fprintf (f, "\nReplacing Expressions\n");
- for (x = 0; x < (int)highest_ssa_version + 1; x++)
+ for (x = 0; x < (int)num_ssa_names + 1; x++)
if (expr[x])
{
stmt = expr[x];
/* Now register partitions for all instances of the variables we
are taking out of SSA form. */
- map = init_var_map (highest_ssa_version + 1);
+ map = init_var_map (num_ssa_names + 1);
register_ssa_partitions_for_vars (vars, map);
/* Now that we have all the partitions registered, translate the
bb_in_list = sbitmap_alloc (last_basic_block);
sbitmap_zero (bb_in_list);
- value_vector = (value *) xmalloc (highest_ssa_version * sizeof (value));
- memset (value_vector, 0, highest_ssa_version * sizeof (value));
+ value_vector = (value *) xmalloc (num_ssa_names * sizeof (value));
+ memset (value_vector, 0, num_ssa_names * sizeof (value));
/* 1 if ssa variable is used in a virtual variable context. */
- virtual_var = sbitmap_alloc (highest_ssa_version);
+ virtual_var = sbitmap_alloc (num_ssa_names);
sbitmap_zero (virtual_var);
/* Initialize default values and simulation flags for PHI nodes, statements
else
debug = NULL;
- map = init_var_map (highest_ssa_version + 1);
+ map = init_var_map (num_ssa_names + 1);
FOR_EACH_BB (bb)
{
/* Now one more pass to make all elements of a partition share the same
root variable. */
- for (x = 1; x <= highest_ssa_version; x++)
+ for (x = 1; x <= num_ssa_names; x++)
{
part_var = partition_to_var (map, x);
if (!part_var)
sbitmap_zero (last_stmt_necessary);
}
- processed = sbitmap_alloc (highest_ssa_version + 1);
+ processed = sbitmap_alloc (num_ssa_names + 1);
sbitmap_zero (processed);
VARRAY_TREE_INIT (worklist, 64, "work list");
/* Create our hash tables. */
avail_exprs = htab_create (1024, avail_expr_hash, avail_expr_eq, free);
- VARRAY_TREE_INIT (const_and_copies, highest_ssa_version, "const_and_copies");
+ VARRAY_TREE_INIT (const_and_copies, num_ssa_names, "const_and_copies");
nonzero_vars = BITMAP_XMALLOC ();
VARRAY_EDGE_INIT (redirection_edges, 20, "redirection_edges");
- VARRAY_GENERIC_PTR_INIT (vrp_data, highest_ssa_version, "vrp_data");
+ VARRAY_GENERIC_PTR_INIT (vrp_data, num_ssa_names, "vrp_data");
/* Setup callbacks for the generic dominator tree walker. */
walk_data.walk_stmts_backward = false;
/* The into SSA translation may have created new SSA_NAMES whic
affect the size of CONST_AND_COPIES and VRP_DATA. */
- VARRAY_GROW (const_and_copies, highest_ssa_version);
- VARRAY_GROW (vrp_data, highest_ssa_version);
+ VARRAY_GROW (const_and_copies, num_ssa_names);
+ VARRAY_GROW (vrp_data, num_ssa_names);
}
/* Reinitialize the various tables. */
sbitmap used_in_virtual_ops;
#endif
- map = init_var_map (highest_ssa_version + 1);
+ map = init_var_map (num_ssa_names + 1);
#if defined ENABLE_CHECKING
used_in_real_ops = sbitmap_alloc (num_referenced_vars);
if (flags & SSA_VAR_MAP_REF_COUNT)
{
map->ref_count
- = (int *)xmalloc (((highest_ssa_version + 1) * sizeof (int)));
- memset (map->ref_count, 0, (highest_ssa_version + 1) * sizeof (int));
+ = (int *)xmalloc (((num_ssa_names + 1) * sizeof (int)));
+ memset (map->ref_count, 0, (num_ssa_names + 1) * sizeof (int));
}
FOR_EACH_BB (bb)
continue;
t = 0;
- for (y = 1; y < highest_ssa_version; y++)
+ for (y = 1; y < num_ssa_names; y++)
{
p = partition_find (map->var_partition, y);
if (map->partition_to_compact)
{
bool err = false;
basic_block bb;
- basic_block *definition_block = xcalloc (highest_ssa_version,
- sizeof (basic_block));
+ basic_block *definition_block = xcalloc (num_ssa_names, sizeof (basic_block));
timevar_push (TV_TREE_SSA_VERIFY);
static void
kill_redundant_phi_nodes (void)
{
- tree *eq_to, *ssa_names;
- unsigned i, ver, aver;
+ tree *eq_to;
+ unsigned i;
basic_block bb;
tree phi, t, stmt, var;
The remaining phi nodes have their uses replaced with their value
in the lattice and the phi node itself is removed. */
- eq_to = xcalloc (highest_ssa_version, sizeof (tree));
-
- /* The SSA_NAMES array holds each SSA_NAME node we encounter
- in a PHI node (indexed by ssa version number).
-
- One could argue that the SSA_NAME manager ought to provide a
- generic interface to get at the SSA_NAME node for a given
- ssa version number. */
- ssa_names = xcalloc (highest_ssa_version, sizeof (tree));
+ eq_to = xcalloc (num_ssa_names, sizeof (tree));
/* We have had cases where computing immediate uses takes a
significant amount of compile time. If we run into such
for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
{
var = PHI_RESULT (phi);
- ver = SSA_NAME_VERSION (var);
- ssa_names[ver] = var;
for (i = 0; i < (unsigned) PHI_NUM_ARGS (phi); i++)
{
}
stmt = SSA_NAME_DEF_STMT (t);
- aver = SSA_NAME_VERSION (t);
- ssa_names[aver] = t;
/* If the defining statement for this argument is not a
phi node or the argument is associated with an abnormal
if (TREE_CODE (stmt) != PHI_NODE
|| SSA_NAME_OCCURS_IN_ABNORMAL_PHI (t))
{
- eq_to[aver] = t;
+ eq_to[SSA_NAME_VERSION (t)] = t;
raise_value (phi, t, eq_to);
}
}
}
/* Now propagate the values. */
- for (i = 0; i < highest_ssa_version; i++)
+ for (i = 0; i < num_ssa_names; i++)
if (eq_to[i]
- && eq_to[i] != ssa_names[i])
- replace_immediate_uses (ssa_names[i], eq_to[i]);
+ && eq_to[i] != ssa_name (i))
+ replace_immediate_uses (ssa_name (i), eq_to[i]);
/* And remove the dead phis. */
- for (i = 0; i < highest_ssa_version; i++)
+ for (i = 0; i < num_ssa_names; i++)
if (eq_to[i]
- && eq_to[i] != ssa_names[i])
+ && eq_to[i] != ssa_name (i))
{
- stmt = SSA_NAME_DEF_STMT (ssa_names[i]);
+ stmt = SSA_NAME_DEF_STMT (ssa_name (i));
remove_phi_node (stmt, 0, bb_for_stmt (stmt));
}
free_df ();
free (eq_to);
- free (ssa_names);
}
struct tree_opt_pass pass_redundant_phi =
#include "tree.h"
#include "varray.h"
#include "ggc.h"
+#include "tree-flow.h"
/* Rewriting a function into SSA form can create a huge number of SSA_NAMEs,
many of which may be thrown away shortly after their creation if jumps
a very well defined lifetime. If someone wants to experiment with that
this is the place to try it. */
-/* Next SSA version number to be allocated. */
-unsigned int highest_ssa_version;
+/* Array of all SSA_NAMEs used in the function. */
+varray_type ssa_names;
/* Free list of SSA_NAMEs. This list is wiped at the end of each function
after we leave SSA form. */
void
init_ssanames (void)
{
- highest_ssa_version = UNUSED_NAME_VERSION + 1;
+ VARRAY_TREE_INIT (ssa_names, 50, "ssa_names table");
+
+ /* Version 0 is special, so reserve the first slot in the table. Though
+ currently unused, we may use version 0 in alias analysis as part of
+ the heuristics used to group aliases when the alias sets are too
+ large. */
+ VARRAY_PUSH_TREE (ssa_names, NULL_TREE);
free_ssanames = NULL;
}
else
{
t = make_node (SSA_NAME);
- SSA_NAME_VERSION (t) = highest_ssa_version++;
+ SSA_NAME_VERSION (t) = num_ssa_names;
+ VARRAY_PUSH_TREE (ssa_names, t);
#ifdef GATHER_STATISTICS
ssa_name_nodes_created++;
#endif
TREE_TYPE (t) = TREE_TYPE (var);
SSA_NAME_VAR (t) = var;
SSA_NAME_DEF_STMT (t) = stmt;
+ SSA_NAME_PTR_INFO (t) = NULL;
return t;
}
+
/* We no longer need the SSA_NAME expression VAR, release it so that
it may be reused.