This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] tree-outof-ssa.c: VECify stmt_list.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: amacleod at redhat dot com
- Date: Tue, 03 May 2005 13:12:08 -0400 (EDT)
- Subject: [patch] tree-outof-ssa.c: VECify stmt_list.
Hi,
Attached is a patch to VECify stmt_list.
Andrew, we have several options here.
o Go with the simple VARRAY -> VEC(tree,gc)* option. (This is what
the patch below does.)
o Allocate and free these work areas on heap in analyze_edges_for_bb
since the use of the memory does not "escape" the function.
o Allocate and free these work areas in perform_edge_inserts so that
you won't have to allocate and free them every time
analyze_edges_for_bb is called.
I would prefer the second and third option, but I am asking you
because you seem to want to reuse the memory from previous call to
analyze_edge_for_bb. Well, reusing the memory may be the only
reasonable thing you can do with VARRAY on GC. :-)
Tested on i686-pc-linux-gnu. Thoughts? Preference?
Kazu Hirata
2005-05-03 Kazu Hirata <kazu@cs.umass.edu>
* tree-outof-ssa.c (stmt_list, analyze_edges_for_bb): Use VEC
instead of VARRAY.
Index: tree-outof-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-outof-ssa.c,v
retrieving revision 2.56
diff -u -d -p -r2.56 tree-outof-ssa.c
--- tree-outof-ssa.c 22 Apr 2005 10:56:55 -0000 2.56
+++ tree-outof-ssa.c 2 May 2005 00:06:53 -0000
@@ -1951,7 +1951,7 @@ rewrite_trees (var_map map, tree *values
/* These are the local work structures used to determine the best place to
insert the copies that were placed on edges by the SSA->normal pass.. */
static varray_type edge_leader = NULL;
-static varray_type GTY(()) stmt_list = NULL;
+static GTY(()) VEC(tree,gc) *stmt_list = NULL;
static bitmap leader_has_match = NULL;
static edge leader_match = NULL;
@@ -2096,14 +2096,14 @@ analyze_edges_for_bb (basic_block bb, FI
if (edge_leader == NULL)
{
VARRAY_EDGE_INIT (edge_leader, 25, "edge_leader");
- VARRAY_TREE_INIT (stmt_list, 25, "stmt_list");
+ stmt_list = VEC_alloc (tree, gc, 25);
leader_has_match = BITMAP_ALLOC (NULL);
}
else
{
#ifdef ENABLE_CHECKING
gcc_assert (VARRAY_ACTIVE_SIZE (edge_leader) == 0);
- gcc_assert (VARRAY_ACTIVE_SIZE (stmt_list) == 0);
+ gcc_assert (VEC_length (tree, stmt_list) == 0);
gcc_assert (bitmap_empty_p (leader_has_match));
#endif
}
@@ -2138,7 +2138,7 @@ analyze_edges_for_bb (basic_block bb, FI
if (!found)
{
VARRAY_PUSH_EDGE (edge_leader, e);
- VARRAY_PUSH_TREE (stmt_list, PENDING_STMT (e));
+ VEC_safe_push (tree, gc, stmt_list, PENDING_STMT (e));
}
}
}
@@ -2149,7 +2149,7 @@ analyze_edges_for_bb (basic_block bb, FI
for (x = 0; x < VARRAY_ACTIVE_SIZE (edge_leader); x++)
bsi_commit_one_edge_insert (VARRAY_EDGE (edge_leader, x), NULL);
VARRAY_POP_ALL (edge_leader);
- VARRAY_POP_ALL (stmt_list);
+ VEC_truncate (tree, stmt_list, 0);
bitmap_clear (leader_has_match);
return;
}
@@ -2177,7 +2177,7 @@ analyze_edges_for_bb (basic_block bb, FI
and use the saved stmt list. */
PENDING_STMT (leader_edge) = NULL;
leader_edge->aux = leader_edge;
- curr_stmt_list = VARRAY_TREE (stmt_list, x);
+ curr_stmt_list = VEC_index (tree, stmt_list, x);
new_edge = make_forwarder_block (leader_edge->dest, same_stmt_list_p,
NULL);
@@ -2207,14 +2207,14 @@ analyze_edges_for_bb (basic_block bb, FI
else
{
e = VARRAY_EDGE (edge_leader, x);
- PENDING_STMT (e) = VARRAY_TREE (stmt_list, x);
+ PENDING_STMT (e) = VEC_index (tree, stmt_list, x);
bsi_commit_one_edge_insert (e, NULL);
}
/* Clear the working data structures. */
VARRAY_POP_ALL (edge_leader);
- VARRAY_POP_ALL (stmt_list);
+ VEC_truncate (tree, stmt_list, 0);
bitmap_clear (leader_has_match);
}