Hi, On Fri, May 16, 2014 at 07:25:59PM +0200, Jan Hubicka wrote: > Hi, > this patch adds code to remove write only static variables. While analyzing > effectivity of LTO on firefox, I noticed that surprisingly large part of > binary's data segment is occupied by these. Fixed thus. > (this is quite trivial transformation, I just never considered it important > enough to work on it). > > The patch goes by marking write only variables in ipa.c (at same time we > discover addressable flag) and also fixes handling of the flags for > aliases. References to variables are then removed by fixup_cfg. > As first cut, I only remove stores without side effects, so copies from > volatile variables are preserved. I also kill LHS of function calls. > I do not attempt to remove asm statements. This means that some references > may be left in the code and therefore the IPA code does not eliminate the > referneces after discovering write only variable and instead it relies > on dead variable elimination to do the job later. Consequently not all write > only variables are removed with WHOPR in the case the references ends up > in different partitions. Something I can address incrementally. > > Also I think dwarf2out should be updated to mark value of the write only > variables as optimized out. Jakub, can you help me with this? > (I do not think it is valid to output the optimized out value of constructor) > > Bootstrapped/regtested x86_64-linux, will commit it later today. > > Honza > > * varpool.c (dump_varpool_node): Dump write-only flag. > * lto-cgraph.c (lto_output_varpool_node, input_varpool_node): Stream > write-only flag. > * tree-cfg.c (execute_fixup_cfg): Remove statements setting write-only > variables. > > > * gcc.c-torture/execute/20101011-1.c: Update testcase. > * gcc.dg/ira-shrinkwrap-prep-1.c: Update testcase. > * gcc.dg/tree-ssa/writeonly.c: New testcase. > * gcc.dg/tree-ssa/ssa-dse-6.c: Update testcase. > * gcc.dg/tree-ssa/pr21559.c: Update testcase. > * gcc.dg/debug/pr35154.c: Update testcase. > * gcc.target/i386/vectorize1.c: Update testcase. > * ipa.c (process_references): New function. > (set_readonly_bit): New function. > (set_writeonly_bit): New function. > (clear_addressable_bit): New function. > (ipa_discover_readonly_nonaddressable_var): Mark write only variables; > fix > handling of aliases. > * cgraph.h (struct varpool_node): Add writeonly flag. >
Unfortunately, this commit has caused the following ICE for me when LTO building 471.omnetpp from SPEC 2006 or Firefox (but not libxul, something that gets built earlier): lto1: internal compiler error: in gimple_get_virt_method_for_vtable, at gimple-fold.c:3276 0x7437a3 gimple_get_virt_method_for_vtable(long, tree_node*, unsigned long, bool*) /home/mjambor/gcc/bisect/src/gcc/gimple-fold.c:3276 0x743993 gimple_get_virt_method_for_binfo(long, tree_node*, bool*) /home/mjambor/gcc/bisect/src/gcc/gimple-fold.c:3377 0x7913f2 possible_polymorphic_call_targets(tree_node*, long, ipa_polymorphic_call_context, bool*, void**, int*) /home/mjambor/gcc/bisect/src/gcc/ipa-devirt.c:1697 0x7b73a9 possible_polymorphic_call_targets /home/mjambor/gcc/bisect/src/gcc/ipa-utils.h:121 0x7b73a9 walk_polymorphic_call_targets /home/mjambor/gcc/bisect/src/gcc/ipa.c:177 0x7b73a9 symtab_remove_unreachable_nodes(bool, _IO_FILE*) /home/mjambor/gcc/bisect/src/gcc/ipa.c:407 0x86bf47 execute_todo /home/mjambor/gcc/bisect/src/gcc/passes.c:1843 Please submit a full bug report... I compile omnetpp with -Ofast -g -flto=8 -fwhole-program -funroll-loops -fpeel-loops -march=native -mtune=native I'm afraid I won't be able to prepare a more reduced testcase very soon. Thanks, Martin