* Remove unused variables from REFERENCED_VARS list
@ 2007-01-12 0:38 Jan Hubicka
2007-01-12 15:24 ` Richard Guenther
0 siblings, 1 reply; 4+ messages in thread
From: Jan Hubicka @ 2007-01-12 0:38 UTC (permalink / raw)
To: gcc-patches, rguenther
Hi,
this patch makes remove_unused_locals to prunt not only unexpanded_var_list but
also referenced_vars that are a lot more commonly traversed. For temporaries
this also makes them available for ggc memory. On tramp3d after early
optimization about 70% of local variables can be reclaimed to GGC this way
reducing peak memory usage from 720 to 630MB.
:ADDPATCH tree-optimization:
Bootstrapped/regtested i686-linux, OK?
Honza
* tree-dfa.c (remove_referenced_var): New function.
* tree-ssa-live.c (remove_unused_locals): Walk referenced vars and
prune referenced vars list too.
* tree-flow.h (remove_referenced_var): Declare.
Index: tree-dfa.c
===================================================================
*** tree-dfa.c (revision 120681)
--- tree-dfa.c (working copy)
*************** add_referenced_var (tree var)
*** 752,757 ****
--- 752,780 ----
}
}
+ /* Remove VAR from the list. */
+
+ void
+ remove_referenced_var (tree var)
+ {
+ var_ann_t v_ann;
+ struct int_tree_map in;
+ void **loc;
+ unsigned int uid = DECL_UID (var);
+
+ clear_call_clobbered (var);
+ v_ann = get_var_ann (var);
+ ggc_free (v_ann);
+ var->base.ann = NULL;
+ gcc_assert (DECL_P (var));
+ in.uid = uid;
+ in.to = var;
+ loc = htab_find_slot_with_hash (gimple_referenced_vars (cfun), &in, uid,
+ NO_INSERT);
+ ggc_free (*loc);
+ htab_clear_slot (gimple_referenced_vars (cfun), loc);
+ }
+
/* Return the virtual variable associated to the non-scalar variable VAR. */
Index: tree-ssa-live.c
===================================================================
*** tree-ssa-live.c (revision 120681)
--- tree-ssa-live.c (working copy)
*************** remove_unused_locals (void)
*** 449,463 ****
{
basic_block bb;
tree t, *cell;
/* Assume all locals are unused. */
! for (t = cfun->unexpanded_var_list; t; t = TREE_CHAIN (t))
! {
! tree var = TREE_VALUE (t);
! if (TREE_CODE (var) != FUNCTION_DECL
! && var_ann (var))
! var_ann (var)->used = false;
! }
/* Walk the CFG marking all referenced symbols. */
FOR_EACH_BB (bb)
--- 449,460 ----
{
basic_block bb;
tree t, *cell;
+ referenced_var_iterator rvi;
+ var_ann_t ann;
/* Assume all locals are unused. */
! FOR_EACH_REFERENCED_VAR (t, rvi)
! var_ann (t)->used = false;
/* Walk the CFG marking all referenced symbols. */
FOR_EACH_BB (bb)
*************** remove_unused_locals (void)
*** 493,503 ****
for (cell = &cfun->unexpanded_var_list; *cell; )
{
tree var = TREE_VALUE (*cell);
- var_ann_t ann;
if (TREE_CODE (var) != FUNCTION_DECL
&& (!(ann = var_ann (var))
|| !ann->used))
{
*cell = TREE_CHAIN (*cell);
continue;
--- 490,499 ----
for (cell = &cfun->unexpanded_var_list; *cell; )
{
tree var = TREE_VALUE (*cell);
if (TREE_CODE (var) != FUNCTION_DECL
&& (!(ann = var_ann (var))
|| !ann->used))
{
*cell = TREE_CHAIN (*cell);
continue;
*************** remove_unused_locals (void)
*** 505,510 ****
--- 501,519 ----
cell = &TREE_CHAIN (*cell);
}
+
+ /* Remove unused variables from REFERENCED_VARs. As an special exception
+ keep the variables that are believed to be aliased. Those can't be
+ easilly removed from the alias sets and and operand caches.
+ They will be removed shortly after next may_alias pass is performed. */
+ FOR_EACH_REFERENCED_VAR (t, rvi)
+ if (!is_global_var (t)
+ && !MTAG_P (t)
+ && TREE_CODE (t) != PARM_DECL
+ && TREE_CODE (t) != RESULT_DECL
+ && !(ann = var_ann (t))->used
+ && !ann->is_aliased && !is_call_clobbered (t) && !ann->symbol_mem_tag)
+ remove_referenced_var (t);
}
Index: tree-flow.h
===================================================================
*** tree-flow.h (revision 120681)
--- tree-flow.h (working copy)
*************** extern void dump_subvars_for (FILE *, tr
*** 698,703 ****
--- 698,704 ----
extern void debug_subvars_for (tree);
extern tree get_virtual_var (tree);
extern void add_referenced_var (tree);
+ extern void remove_referenced_var (tree);
extern void mark_symbols_for_renaming (tree);
extern void find_new_referenced_vars (tree *);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove unused variables from REFERENCED_VARS list
2007-01-12 0:38 Remove unused variables from REFERENCED_VARS list Jan Hubicka
@ 2007-01-12 15:24 ` Richard Guenther
2007-01-12 18:37 ` Jan Hubicka
2007-01-15 1:17 ` Jan Hubicka
0 siblings, 2 replies; 4+ messages in thread
From: Richard Guenther @ 2007-01-12 15:24 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches, rguenther
On 1/12/07, Jan Hubicka <jh@suse.cz> wrote:
> Hi,
> this patch makes remove_unused_locals to prunt not only unexpanded_var_list but
> also referenced_vars that are a lot more commonly traversed. For temporaries
> this also makes them available for ggc memory. On tramp3d after early
> optimization about 70% of local variables can be reclaimed to GGC this way
> reducing peak memory usage from 720 to 630MB.
>
> :ADDPATCH tree-optimization:
> Bootstrapped/regtested i686-linux, OK?
This is ok (thanks for this work!).
Richard.
> Honza
> * tree-dfa.c (remove_referenced_var): New function.
> * tree-ssa-live.c (remove_unused_locals): Walk referenced vars and
> prune referenced vars list too.
> * tree-flow.h (remove_referenced_var): Declare.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove unused variables from REFERENCED_VARS list
2007-01-12 15:24 ` Richard Guenther
@ 2007-01-12 18:37 ` Jan Hubicka
2007-01-15 1:17 ` Jan Hubicka
1 sibling, 0 replies; 4+ messages in thread
From: Jan Hubicka @ 2007-01-12 18:37 UTC (permalink / raw)
To: Richard Guenther; +Cc: Jan Hubicka, gcc-patches, rguenther
> On 1/12/07, Jan Hubicka <jh@suse.cz> wrote:
> >Hi,
> >this patch makes remove_unused_locals to prunt not only
> >unexpanded_var_list but
> >also referenced_vars that are a lot more commonly traversed. For
> >temporaries
> >this also makes them available for ggc memory. On tramp3d after early
> >optimization about 70% of local variables can be reclaimed to GGC this way
> >reducing peak memory usage from 720 to 630MB.
> >
> >:ADDPATCH tree-optimization:
> >Bootstrapped/regtested i686-linux, OK?
>
> This is ok (thanks for this work!).
Thank you too! I would like to commit it after C++ tester stomach the
early optimization changes, but for some reason the last result on
vangelis seems to be from 10th. Do you have any idea what is going
wrong?
Thanks,
Honza
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove unused variables from REFERENCED_VARS list
2007-01-12 15:24 ` Richard Guenther
2007-01-12 18:37 ` Jan Hubicka
@ 2007-01-15 1:17 ` Jan Hubicka
1 sibling, 0 replies; 4+ messages in thread
From: Jan Hubicka @ 2007-01-15 1:17 UTC (permalink / raw)
To: Richard Guenther; +Cc: Jan Hubicka, gcc-patches, rguenther
> On 1/12/07, Jan Hubicka <jh@suse.cz> wrote:
> >Hi,
> >this patch makes remove_unused_locals to prunt not only
> >unexpanded_var_list but
> >also referenced_vars that are a lot more commonly traversed. For
> >temporaries
> >this also makes them available for ggc memory. On tramp3d after early
> >optimization about 70% of local variables can be reclaimed to GGC this way
> >reducing peak memory usage from 720 to 630MB.
> >
> >:ADDPATCH tree-optimization:
> >Bootstrapped/regtested i686-linux, OK?
>
> This is ok (thanks for this work!).
Hi,
for a record this is memory report from this patch and the EH cleanup.
As expected it brings nice savings on Gerald's testcase (smaller than on
tramp3d, but still). However PR rtl-optimization/28071 seems to regress
somewhat. I can't say it was expected, perhaps removing dead variables
from the list tends to change optimization decisions (hopefully in
positive way).
I will look into the dumps once they appear on the webpages to do some
more analysis.
There are also nice -O3 savings for the same testcase, just a week ago
we needed 920MB, so we have 30% drop. (by early inlining)
Honza
comparing Gerald's testcase PR8361 compilation at -O1 level:
Peak amount of GGC memory allocated before garbage collecting run decreased from 102899k to 98615k, overall -4.34%
Peak amount of GGC memory still allocated after garbage collecting decreased from 101880k to 97638k, overall -4.34%
Overall memory needed: 132838k -> 130302k
Peak memory use before GGC: 102899k -> 98615k
Peak memory use after GGC: 101880k -> 97638k
Maximum of released memory in single GGC run: 17926k -> 17925k
Garbage: 397860k -> 394895k
Leak: 50038k -> 50037k
Overhead: 53236k -> 53231k
GGC runs: 574 -> 572
comparing Gerald's testcase PR8361 compilation at -O2 level:
Peak amount of GGC memory allocated before garbage collecting run decreased from 103003k to 98683k, overall -4.38%
Peak amount of GGC memory still allocated after garbage collecting decreased from 101947k to 97705k, overall -4.34%
Overall memory needed: 132878k -> 130362k
Peak memory use before GGC: 103003k -> 98683k
Peak memory use after GGC: 101947k -> 97705k
Maximum of released memory in single GGC run: 17926k -> 17924k
Garbage: 454649k -> 451692k
Leak: 50816k -> 50815k
Overhead: 46330k -> 46288k
GGC runs: 630 -> 633
comparing Gerald's testcase PR8361 compilation at -O3 level:
Peak amount of GGC memory allocated before garbage collecting run decreased from 104577k to 100272k, overall -4.29%
Peak amount of GGC memory still allocated after garbage collecting decreased from 103536k to 99239k, overall -4.33%
Overall memory needed: 134754k -> 132182k
Peak memory use before GGC: 104577k -> 100272k
Peak memory use after GGC: 103536k -> 99239k
Maximum of released memory in single GGC run: 18326k -> 18325k
Garbage: 470546k -> 467160k
Leak: 51030k -> 51029k
Overhead: 45782k -> 45801k
GGC runs: 643 -> 642
comparing PR rtl-optimization/28071 testcase compilation at -O1 level:
Overall memory allocated via mmap and sbrk increased from 417842k to 436710k, overall 4.52%
Peak amount of GGC memory allocated before garbage collecting increased from 200591k to 202594k, overall 1.00%
Overall memory needed: 417842k -> 436710k
Peak memory use before GGC: 200591k -> 202594k
Peak memory use after GGC: 193289k -> 192571k
Maximum of released memory in single GGC run: 112413k -> 137171k
Garbage: 281276k -> 278226k
Leak: 29804k
Overhead: 32031k -> 32030k
GGC runs: 92
comparing PR rtl-optimization/28071 testcase compilation at -O2 level:
Overall memory allocated via mmap and sbrk increased from 341514k to 365202k, overall 6.94%
Peak amount of GGC memory allocated before garbage collecting increased from 200583k to 207227k, overall 3.31%
Overall memory needed: 341514k -> 365202k
Peak memory use before GGC: 200583k -> 207227k
Peak memory use after GGC: 193281k -> 192563k
Maximum of released memory in single GGC run: 111840k -> 140362k
Garbage: 358332k -> 355277k
Leak: 30387k
Overhead: 47186k -> 47185k
GGC runs: 99 -> 98
comparing PR rtl-optimization/28071 testcase compilation at -O3 -fno-tree-pre -fno-tree-fre level:
Peak amount of GGC memory allocated before garbage collecting run decreased from 299944k to 282245k, overall -6.27%
Overall memory needed: 712662k -> 710702k
Peak memory use before GGC: 299944k -> 282245k
Peak memory use after GGC: 278930k -> 273215k
Maximum of released memory in single GGC run: 158597k -> 138326k
Garbage: 452446k -> 448504k
Leak: 45440k
Overhead: 56089k -> 56089k
GGC runs: 97
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-01-15 1:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-12 0:38 Remove unused variables from REFERENCED_VARS list Jan Hubicka
2007-01-12 15:24 ` Richard Guenther
2007-01-12 18:37 ` Jan Hubicka
2007-01-15 1:17 ` Jan Hubicka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).