Patchwork Rewrite lto-symtab to work on symbol table

login
register
mail settings
Submitter Richard Guenther
Date Sept. 25, 2012, 11:06 a.m.
Message ID <CAFiYyc1rAhTh7Cof23cE=g5MRWx4EeWyCazXBFM_qrDh44ax=Q@mail.gmail.com>
Download mbox | patch
Permalink /patch/186768/
State New
Headers show

Comments

Richard Guenther - Sept. 25, 2012, 11:06 a.m.
On Mon, Sep 24, 2012 at 6:10 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Sep 24, 2012 at 8:50 AM, Martin Jambor <mjambor@suse.cz> wrote:
>> Hi,
>>
>> On Tue, Sep 18, 2012 at 03:35:45PM +0200, Jan Hubicka wrote:
>>> Hi,
>>> this patch reorganize lto-symtab to work across symtab's symbol table instead
>>> of building its own.  This simplifies things a bit and with the previous
>>> changes it is rather straighforward - i.e. replace all uses of
>>> lto_symtab_entry_t by symtab_node.
>>>
>>> There are few differences in between the symtab as built by lto-symtab and
>>> our symbol table.  In one direction the declarations that are not going to be
>>> output to final assembly (i.e. are used by debug info and such) are not in
>>> symbol table and consequentely they no longer get merged.  I think this is fine.
>>>
>>> Other difference is that symbol table contains some symbols that are not really
>>> symbols in classical definition - such as inline clones or functions held in
>>> table only for purposes of materialization.  I added symtab_real_symbol_p
>>> predicate for this.  It would make more sense to exclude those from the
>>> assembler name hash and drop checks I added to lto-symtab.c.  I plan to work on
>>> this incrementally - it is not completely trivial. The symbol can become
>>> non-real in several ways and it will need bit of work to get this consistent.
>>>
>>> Bootstrapped/regtested x86_64-linux, tested by building Mozilla, Qt and other
>>> stuff with LTO. OK?
>>>
>>> Honza
>>>
>>>       * symtab.c (insert_to_assembler_name_hash): Do not insert
>>>       register vars.
>>>       (unlink_from_assembler_name_hash): NULL out pointers of unlinked
>>>       var.
>>>       (symtab_prevail_in_asm_name_hash): New.
>>>       (symtab_initialize_asm_name_hash): Break out from ...
>>>       (symtab_node_for_asm): ... here.
>>>       (dump_symtab_base): Dump LTO file data.
>>>       (verify_symtab_base): Register vars are not in symtab.
>>>       * cgraph.h (symtab_initialize_asm_name_hash,
>>>       symtab_prevail_in_asm_name_hash): New functions.
>>>       (symtab_real_symbol_p): New inline.
>>>       * lto-symtab.c: Do not include gt-lto-symtab.h.
>>>       (lto_symtab_entry_def): Remove.
>>>       (lto_symtab_entry_t): Remove.
>>>       (lto_symtab_identifiers): Remove.
>>>       (lto_symtab_free): Remove.
>>>       (lto_symtab_entry_hash): Remove.
>>>       (lto_symtab_entry_eq): Remove.
>>>       (lto_symtab_entry_marked_p): Remove.
>>>       (lto_symtab_maybe_init_hash_table): Remove.
>>>       (resolution_guessed_p, set_resolution_guessed): New functions.
>>>       (lto_symtab_register_decl): Only set resolution info.
>>>       (lto_symtab_get, lto_symtab_get_resolution): Remove.
>>>       (lto_symtab_merge): Reorg to work across symtab; do nothing if decls
>>>       are same.
>>>       (lto_symtab_resolve_replaceable_p): Reorg to work on symtab.
>>>       (lto_symtab_resolve_can_prevail_p): Likewise; only real symbols can
>>>       prevail.
>>>       (lto_symtab_resolve_symbols): Reorg to work on symtab.
>>>       (lto_symtab_merge_decls_2): Likewise.
>>>       (lto_symtab_merge_decls_1): Likewise; add debug dumps.
>>>       (lto_symtab_merge_decls): Likewise; do not merge at ltrans stage.
>>>       (lto_symtab_merge_cgraph_nodes_1): Reorg to work on symtab.
>>>       (lto_symtab_merge_cgraph_nodes): Likewise; do not merge at ltrans stage.
>>>       (lto_symtab_prevailing_decl): Rewrite to lookup into symtab.
>>>       * lto-streaer.h (lto_symtab_free): Remove.
>>>       * lto-cgraph.c (add_references): Cleanup.
>>>       * varpool.c (varpool_assemble_decl): Skip hard regs.
>>>
>>>       * lto.c (lto_materialize_function): Update confused comment.
>>>       (read_cgraph_and_symbols): Do not free symtab.
>>
>> Unfortunately, this patch breaks SPEC2006 povray LTO build for me.
>> I'm getting:
>>
>> In file included from :168:0:
>> lighting.cpp: In function 'InitMallocPools':
>> lighting.cpp:5971:13: error: address taken, but ADDRESSABLE bit not set
>>  static void InitMallocPools(void)
>>              ^
>> PHI argument
>> &Frame.Number_Of_Light_Sources;
>> for PHI node
>> _191 = PHI <&Frame.Number_Of_Light_Sources(100), &D.7040(101)>
>> lighting.cpp:5971:13: internal compiler error: verify_ssa failed
>>
>> I'm currently a bit too busy to try to reduce this,  I hope you'll be
>> able to reproduce the issue yourself easily though.  If not, ping me
>> on IRC.
>>
>> Thanks,
>>
>
> Many of SPEC CPU 2K/2006 benchmarks failed with LTO:
>
> http://gcc.gnu.org/ml/gcc-regression/2012-09/msg00419.html
> http://gcc.gnu.org/ml/gcc-regression/2012-09/msg00392.html

Maybe


will fix it.

>
> --
> H.J.

Patch

Index: lto-symtab.c
===================================================================
--- lto-symtab.c        (revision 191694)
+++ lto-symtab.c        (working copy)
@@ -566,7 +566,7 @@  lto_symtab_merge_decls_1 (symtab_node fi

   /* Merge the chain to the single prevailing decl and diagnose
      mismatches.  */
-  lto_symtab_merge_decls_2 (first, diagnosed_p);
+  lto_symtab_merge_decls_2 (prevailing, diagnosed_p);

   if (cgraph_dump_file)
     {