This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: LTO/WHOPR summary streaming fixes
On Thu, 22 Oct 2009, Richard Guenther wrote:
> On Thu, 22 Oct 2009, Jan Hubicka wrote:
>
> > Hi,
> > this should be final version of patch. Tested on x86_64-linux and also
> > Richard kindly tested it works with Spec2006.
> > The patch fixes ICE in ipa-cp seen on libquantum. OK?
>
> Ok. I'll think about the fixup problem. I think we can easily delay
> cgraph node merging until after fixup, then read in the summaries and
> then apply the node merging.
Like this (untested).
Richard.
2009-10-22 Richard Guenther <rguenther@suse.de>
* lto-streamer.h (lto_symtab_merge_cgraph_nodes): Declare.
* lto-symtab.c (lto_symtab_merge): Do not merge the cgraph here.
(lto_symtab_merge_decls_1): Do not drop non-prevailing entries here.
(lto_symtab_merge_cgraph_nodes_1): New function.
(lto_symtab_merge_cgraph_nodes): Likewise.
lto/
* lto.c (read_cgraph_and_symbols): Move IPA summary reading
inbetween decl and type fixup and cgraph merging.
Index: gcc/lto-streamer.h
===================================================================
*** gcc/lto-streamer.h (revision 153445)
--- gcc/lto-streamer.h (working copy)
*************** void input_cgraph (void);
*** 843,848 ****
--- 843,849 ----
extern void lto_symtab_register_decl (tree, ld_plugin_symbol_resolution_t,
struct lto_file_decl_data *);
extern void lto_symtab_merge_decls (void);
+ extern void lto_symtab_merge_cgraph_nodes (void);
extern tree lto_symtab_prevailing_decl (tree decl);
extern enum ld_plugin_symbol_resolution lto_symtab_get_resolution (tree decl);
extern void lto_symtab_clear_resolution (tree decl);
Index: gcc/lto-symtab.c
===================================================================
*** gcc/lto-symtab.c (revision 153445)
--- gcc/lto-symtab.c (working copy)
*************** lto_symtab_merge (lto_symtab_entry_t pre
*** 239,249 ****
TREE_ADDRESSABLE (prevailing_decl) |= TREE_ADDRESSABLE (decl);
TREE_ADDRESSABLE (decl) |= TREE_ADDRESSABLE (prevailing_decl);
- /* Replace a cgraph node of entry with the prevailing one. */
- if (TREE_CODE (decl) == FUNCTION_DECL
- && (node = cgraph_get_node (decl)) != NULL)
- lto_cgraph_replace_node (node, cgraph_get_node (prevailing_decl));
-
/* The linker may ask us to combine two incompatible symbols.
Detect this case and notify the caller of required diagnostics. */
--- 239,244 ----
*************** lto_symtab_merge_decls_1 (void **slot, v
*** 599,607 ****
mismatches. */
lto_symtab_merge_decls_2 (slot);
- /* Drop all but the prevailing decl from the symtab. */
- prevailing->next = NULL;
-
return 1;
}
--- 594,599 ----
*************** lto_symtab_merge_decls (void)
*** 614,619 ****
--- 606,646 ----
htab_traverse (lto_symtab_identifiers, lto_symtab_merge_decls_1, NULL);
}
+ /* Helper to process the decl chain for the symbol table entry *SLOT. */
+
+ static int
+ lto_symtab_merge_cgraph_nodes_1 (void **slot, void *data ATTRIBUTE_UNUSED)
+ {
+ lto_symtab_entry_t e, prevailing = (lto_symtab_entry_t) *slot;
+ struct cgraph_node *prevailing_node;
+
+ if (TREE_CODE (prevailing->decl) != FUNCTION_DECL)
+ return 1;
+
+ /* Replace the cgraph node of each entry with the prevailing one. */
+ prevailing_node = cgraph_get_node (prevailing->decl);
+ for (e = prevailing->next; e; e = e->next)
+ {
+ struct cgraph_node *node;
+ if ((node = cgraph_get_node (e->decl)) != NULL)
+ lto_cgraph_replace_node (node, prevailing_node);
+ }
+
+ /* Drop all but the prevailing decl from the symtab. */
+ prevailing->next = NULL;
+
+ return 1;
+ }
+
+ /* Merge cgraph nodes according to the symbol merging done by
+ lto_symtab_merge_decls. */
+
+ void
+ lto_symtab_merge_cgraph_nodes (void)
+ {
+ lto_symtab_maybe_init_hash_table ();
+ htab_traverse (lto_symtab_identifiers, lto_symtab_merge_cgraph_nodes_1, NULL);
+ }
/* Given the decl DECL, return the prevailing decl with the same name. */
Index: gcc/lto/lto.c
===================================================================
*** gcc/lto/lto.c (revision 153445)
--- gcc/lto/lto.c (working copy)
*************** read_cgraph_and_symbols (unsigned nfiles
*** 1823,1833 ****
/* Read the callgraph. */
input_cgraph ();
/* Read the IPA summary data. */
ipa_read_summaries ();
! /* Merge global decls. */
! lto_symtab_merge_decls ();
/* Mark cgraph nodes needed in the merged cgraph
This normally happens in whole-program pass, but for
--- 1823,1842 ----
/* Read the callgraph. */
input_cgraph ();
+ /* Merge global decls. */
+ lto_symtab_merge_decls ();
+
+ /* Fixup all decls and types. */
+ lto_fixup_decls (all_file_decl_data);
+
+ /* Free the type hash tables. */
+ free_gimple_type_tables ();
+
/* Read the IPA summary data. */
ipa_read_summaries ();
! /* Finally merge the cgraph according to the decl merging decisions. */
! lto_symtab_merge_cgraph_nodes ();
/* Mark cgraph nodes needed in the merged cgraph
This normally happens in whole-program pass, but for
*************** read_cgraph_and_symbols (unsigned nfiles
*** 1844,1855 ****
timevar_push (TV_IPA_LTO_DECL_IO);
- /* Fixup all decls and types. */
- lto_fixup_decls (all_file_decl_data);
-
- /* Free the type hash tables. */
- free_gimple_type_tables ();
-
/* FIXME lto. This loop needs to be changed to use the pass manager to
call the ipa passes directly. */
if (!errorcount)
--- 1853,1858 ----