From f901fae2bc22e37c071326f77d45721c30c5e400 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 5 Apr 2012 11:30:52 +0000 Subject: [PATCH] 2012-04-05 Richard Guenther * tree-ssanames.c (release_dead_ssa_names): Compact the SSA version namespace as we release the freelist. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186162 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/tree-ssanames.c | 31 +++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bd45eb7..8273970 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2012-04-05 Richard Guenther + * tree-ssanames.c (release_dead_ssa_names): Compact the SSA + version namespace as we release the freelist. + +2012-04-05 Richard Guenther + * tree-nrv.c (tree_nrv): Release VDEFs. * tree-sra.c (sra_modify_constructor_assign): Likewise. (sra_modify_assign): Likewise. diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index 42eb924..7c31550 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -325,14 +325,14 @@ replace_ssa_name_symbol (tree ssa_name, tree sym) TREE_TYPE (ssa_name) = TREE_TYPE (sym); } -/* Return SSA names that are unused to GGC memory. This is used to keep - footprint of compiler during interprocedural optimization. - As a side effect the SSA_NAME_VERSION number reuse is reduced - so this function should not be used too often. */ +/* Return SSA names that are unused to GGC memory and compact the SSA + version namespace. This is used to keep footprint of compiler during + interprocedural optimization. */ static unsigned int release_dead_ssa_names (void) { tree t; + unsigned i, j; int n = VEC_length (tree, FREE_SSANAMES (cfun)); referenced_var_iterator rvi; @@ -340,14 +340,33 @@ release_dead_ssa_names (void) eventually dead variables so a bunch of memory is held live. */ FOR_EACH_REFERENCED_VAR (cfun, t, rvi) set_current_def (t, NULL); + /* Now release the freelist. */ VEC_free (tree, gc, FREE_SSANAMES (cfun)); FREE_SSANAMES (cfun) = NULL; + /* And compact the SSA number space. We make sure to not change the + relative order of SSA versions. */ + for (i = 1, j = 1; i < VEC_length (tree, cfun->gimple_df->ssa_names); ++i) + { + tree name = ssa_name (i); + if (name) + { + if (i != j) + { + SSA_NAME_VERSION (name) = j; + VEC_replace (tree, cfun->gimple_df->ssa_names, j, name); + } + j++; + } + } + VEC_truncate (tree, cfun->gimple_df->ssa_names, j); + statistics_counter_event (cfun, "SSA names released", n); + statistics_counter_event (cfun, "SSA name holes removed", i - j); if (dump_file) - fprintf (dump_file, "Released %i names, %.2f%%\n", - n, n * 100.0 / num_ssa_names); + fprintf (dump_file, "Released %i names, %.2f%%, removed %i holes\n", + n, n * 100.0 / num_ssa_names, i - j); return 0; } -- 2.7.4