This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Make SCCVN use an obstack for aux data sturctures
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 28 Feb 2008 16:22:29 +0100 (CET)
- Subject: [PATCH] Make SCCVN use an obstack for aux data sturctures
This patch by Steven implements $SUBJECT which should save some time
and memory.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to mainline.
Richard.
2008-02-28 Steven Bosscher <stevenb.gcc@gmail.com>
* tree-ssa-sccvn (vn_ssa_aux_obstack): New obstack.
(VN_INFO_GET): Allocate new objects on the obstack.
(init_scc_vn): Initialize the obstack. Use XDELETE instead of free
for rpo_numbers_temp, for consistency.
(free_scc_vn): Free the obstack.
Index: tree-ssa-sccvn.c
===================================================================
*** tree-ssa-sccvn.c (revision 131489)
--- tree-ssa-sccvn.c (working copy)
*************** static VEC (tree, heap) *sccstack;
*** 241,249 ****
DEF_VEC_P(vn_ssa_aux_t);
DEF_VEC_ALLOC_P(vn_ssa_aux_t, heap);
! /* Table of vn_ssa_aux_t's, one per ssa_name. */
static VEC (vn_ssa_aux_t, heap) *vn_ssa_aux_table;
/* Return the value numbering information for a given SSA name. */
--- 241,252 ----
DEF_VEC_P(vn_ssa_aux_t);
DEF_VEC_ALLOC_P(vn_ssa_aux_t, heap);
! /* Table of vn_ssa_aux_t's, one per ssa_name. The vn_ssa_aux_t objects
! are allocated on an obstack for locality reasons, and to free them
! without looping over the VEC. */
static VEC (vn_ssa_aux_t, heap) *vn_ssa_aux_table;
+ static struct obstack vn_ssa_aux_obstack;
/* Return the value numbering information for a given SSA name. */
*************** VN_INFO_SET (tree name, vn_ssa_aux_t val
*** 264,276 ****
SSA_NAME_VERSION (name), value);
}
! /* Get the value numbering info for a given SSA name, creating it if
! it does not exist. */
vn_ssa_aux_t
VN_INFO_GET (tree name)
{
! vn_ssa_aux_t newinfo = XCNEW (struct vn_ssa_aux);
if (SSA_NAME_VERSION (name) >= VEC_length (vn_ssa_aux_t, vn_ssa_aux_table))
VEC_safe_grow (vn_ssa_aux_t, heap, vn_ssa_aux_table,
SSA_NAME_VERSION (name) + 1);
--- 267,282 ----
SSA_NAME_VERSION (name), value);
}
! /* Initialize the value numbering info for a given SSA name.
! This should be called just once for every SSA name. */
vn_ssa_aux_t
VN_INFO_GET (tree name)
{
! vn_ssa_aux_t newinfo;
!
! newinfo = obstack_alloc (&vn_ssa_aux_obstack, sizeof (struct vn_ssa_aux));
! memset (newinfo, 0, sizeof (struct vn_ssa_aux));
if (SSA_NAME_VERSION (name) >= VEC_length (vn_ssa_aux_t, vn_ssa_aux_table))
VEC_safe_grow (vn_ssa_aux_t, heap, vn_ssa_aux_table,
SSA_NAME_VERSION (name) + 1);
*************** init_scc_vn (void)
*** 2005,2010 ****
--- 2011,2018 ----
/* VEC_alloc doesn't actually grow it to the right size, it just
preallocates the space to do so. */
VEC_safe_grow (vn_ssa_aux_t, heap, vn_ssa_aux_table, num_ssa_names + 1);
+ gcc_obstack_init (&vn_ssa_aux_obstack);
+
shared_lookup_phiargs = NULL;
shared_lookup_vops = NULL;
shared_lookup_references = NULL;
*************** init_scc_vn (void)
*** 2018,2024 ****
for (j = 0; j < n_basic_blocks - NUM_FIXED_BLOCKS; j++)
rpo_numbers[rpo_numbers_temp[j]] = j;
! free (rpo_numbers_temp);
VN_TOP = create_tmp_var_raw (void_type_node, "vn_top");
--- 2026,2032 ----
for (j = 0; j < n_basic_blocks - NUM_FIXED_BLOCKS; j++)
rpo_numbers[rpo_numbers_temp[j]] = j;
! XDELETE (rpo_numbers_temp);
VN_TOP = create_tmp_var_raw (void_type_node, "vn_top");
*************** free_scc_vn (void)
*** 2069,2087 ****
VEC_free (tree, gc, shared_lookup_vops);
VEC_free (vn_reference_op_s, heap, shared_lookup_references);
XDELETEVEC (rpo_numbers);
for (i = 0; i < num_ssa_names; i++)
{
tree name = ssa_name (i);
! if (name)
! {
! XDELETE (VN_INFO (name));
! if (SSA_NAME_VALUE (name) &&
! TREE_CODE (SSA_NAME_VALUE (name)) == VALUE_HANDLE)
! SSA_NAME_VALUE (name) = NULL;
! }
}
!
VEC_free (vn_ssa_aux_t, heap, vn_ssa_aux_table);
VEC_free (tree, heap, sccstack);
free_vn_table (valid_info);
XDELETE (valid_info);
--- 2077,2094 ----
VEC_free (tree, gc, shared_lookup_vops);
VEC_free (vn_reference_op_s, heap, shared_lookup_references);
XDELETEVEC (rpo_numbers);
+
for (i = 0; i < num_ssa_names; i++)
{
tree name = ssa_name (i);
! if (name
! && SSA_NAME_VALUE (name)
! && TREE_CODE (SSA_NAME_VALUE (name)) == VALUE_HANDLE)
! SSA_NAME_VALUE (name) = NULL;
}
! obstack_free (&vn_ssa_aux_obstack, NULL);
VEC_free (vn_ssa_aux_t, heap, vn_ssa_aux_table);
+
VEC_free (tree, heap, sccstack);
free_vn_table (valid_info);
XDELETE (valid_info);