Commit 2d6e4603 by Jan Hubicka Committed by Jan Hubicka

re PR c++/57038 (Latest libreoffice compilation fails with enabled LTO)


	PR lto/57038
	PR lto/47375
	* lto-symtab.c (lto_symtab_symbol_p): Add external symbol; weakrefs are
	not external.
	(lto_symtab_merge_decls): Fix thinko when dealing with non-lto_symtab decls.
	(lto_symtab_merge_cgraph_nodes): Use lto_symtab_symbol_p.
	(lto_symtab_prevailing_decl): Get int sync with lto_symtab_symbol_p.
	* varpool.c (dump_varpool_node): Dump more flags.

	* lto-partition.c (get_symbol_class): Fix weakrefs.
	(lto_balanced_map): Fix weakrefs.
	(privatize_symbol_name): Remove unnecesary label.
	(rename_statics): Handle weakrefs as statics.

	* gcc.dg/lto/attr-weakref-1_0.c: New testcase.
	* gcc.dg/lto/attr-weakref-1_1.c: New testcase.
	* gcc.dg/lto/attr-weakref-1_2.c: New testcase.

From-SVN: r198917
parent 83f44b39
2013-05-15 Jan Hubicka <jh@suse.cz>
PR lto/57038
PR lto/47375
* lto-symtab.c (lto_symtab_symbol_p): Add external symbol; weakrefs are
not external.
(lto_symtab_merge_decls): Fix thinko when dealing with non-lto_symtab decls.
(lto_symtab_merge_cgraph_nodes): Use lto_symtab_symbol_p.
(lto_symtab_prevailing_decl): Get int sync with lto_symtab_symbol_p.
* varpool.c (dump_varpool_node): Dump more flags.
2013-05-15 Ganesh Gopalasubramanian <Ganesh.Gopalasubramanian@amd.com> 2013-05-15 Ganesh Gopalasubramanian <Ganesh.Gopalasubramanian@amd.com>
* config/i386/i386.c (processor_alias_table): Add instruction * config/i386/i386.c (processor_alias_table): Add instruction
......
...@@ -227,13 +227,16 @@ lto_symtab_resolve_replaceable_p (symtab_node e) ...@@ -227,13 +227,16 @@ lto_symtab_resolve_replaceable_p (symtab_node e)
} }
/* Return true, if the symbol E should be resolved by lto-symtab. /* Return true, if the symbol E should be resolved by lto-symtab.
Those are all real symbols that are not static (we handle renaming Those are all external symbols and all real symbols that are not static (we
of static later in partitioning). */ handle renaming of static later in partitioning). */
static bool static bool
lto_symtab_symbol_p (symtab_node e) lto_symtab_symbol_p (symtab_node e)
{ {
if (!TREE_PUBLIC (e->symbol.decl)) if (!TREE_PUBLIC (e->symbol.decl) && !DECL_EXTERNAL (e->symbol.decl))
return false;
/* weakrefs are really static variables that are made external by a hack. */
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (e->symbol.decl)))
return false; return false;
return symtab_real_symbol_p (e); return symtab_real_symbol_p (e);
} }
...@@ -528,10 +531,19 @@ lto_symtab_merge_decls (void) ...@@ -528,10 +531,19 @@ lto_symtab_merge_decls (void)
symtab_initialize_asm_name_hash (); symtab_initialize_asm_name_hash ();
FOR_EACH_SYMBOL (node) FOR_EACH_SYMBOL (node)
if (TREE_PUBLIC (node->symbol.decl) if (lto_symtab_symbol_p (node)
&& node->symbol.next_sharing_asm_name && node->symbol.next_sharing_asm_name)
&& !node->symbol.previous_sharing_asm_name) {
lto_symtab_merge_decls_1 (node); symtab_node n;
/* To avoid duplicated work, see if this is first real symbol in the
chain. */
for (n = node->symbol.previous_sharing_asm_name;
n && !lto_symtab_symbol_p (n); n = n->symbol.previous_sharing_asm_name)
;
if (!n)
lto_symtab_merge_decls_1 (node);
}
} }
/* Helper to process the decl chain for the symbol table entry *SLOT. */ /* Helper to process the decl chain for the symbol table entry *SLOT. */
...@@ -574,7 +586,7 @@ lto_symtab_merge_cgraph_nodes (void) ...@@ -574,7 +586,7 @@ lto_symtab_merge_cgraph_nodes (void)
if (!flag_ltrans) if (!flag_ltrans)
FOR_EACH_SYMBOL (node) FOR_EACH_SYMBOL (node)
if (TREE_PUBLIC (node->symbol.decl) if (lto_symtab_symbol_p (node)
&& node->symbol.next_sharing_asm_name && node->symbol.next_sharing_asm_name
&& !node->symbol.previous_sharing_asm_name) && !node->symbol.previous_sharing_asm_name)
lto_symtab_merge_cgraph_nodes_1 (node); lto_symtab_merge_cgraph_nodes_1 (node);
...@@ -602,7 +614,7 @@ lto_symtab_prevailing_decl (tree decl) ...@@ -602,7 +614,7 @@ lto_symtab_prevailing_decl (tree decl)
symtab_node ret; symtab_node ret;
/* Builtins and local symbols are their own prevailing decl. */ /* Builtins and local symbols are their own prevailing decl. */
if (!TREE_PUBLIC (decl) || is_builtin_fn (decl)) if ((!TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl)) || is_builtin_fn (decl))
return decl; return decl;
/* DECL_ABSTRACTs are their own prevailng decl. */ /* DECL_ABSTRACTs are their own prevailng decl. */
...@@ -614,6 +626,11 @@ lto_symtab_prevailing_decl (tree decl) ...@@ -614,6 +626,11 @@ lto_symtab_prevailing_decl (tree decl)
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl)) if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
return decl; return decl;
/* As an anoying special cases weakrefs are really static variables with
EXTERNAL flag. */
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
return decl;
/* Ensure DECL_ASSEMBLER_NAME will not set assembler name. */ /* Ensure DECL_ASSEMBLER_NAME will not set assembler name. */
gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl)); gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl));
......
2013-05-15 Jan Hubicka <jh@suse.cz>
PR lto/57038
PR lto/47375
* lto-partition.c (get_symbol_class): Fix weakrefs.
(lto_balanced_map): Fix weakrefs.
(privatize_symbol_name): Remove unnecesary label.
(rename_statics): Handle weakrefs as statics.
2013-05-09 Jan Hubicka <jh@suse.cz> 2013-05-09 Jan Hubicka <jh@suse.cz>
Richard Biener <rguenther@suse.de> Richard Biener <rguenther@suse.de>
......
...@@ -59,6 +59,10 @@ get_symbol_class (symtab_node node) ...@@ -59,6 +59,10 @@ get_symbol_class (symtab_node node)
if (cnode && cnode->global.inlined_to) if (cnode && cnode->global.inlined_to)
return SYMBOL_DUPLICATE; return SYMBOL_DUPLICATE;
/* Weakref aliases are always duplicated. */
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
return SYMBOL_DUPLICATE;
/* External declarations are external. */ /* External declarations are external. */
if (DECL_EXTERNAL (node->symbol.decl)) if (DECL_EXTERNAL (node->symbol.decl))
return SYMBOL_EXTERNAL; return SYMBOL_EXTERNAL;
...@@ -79,10 +83,6 @@ get_symbol_class (symtab_node node) ...@@ -79,10 +83,6 @@ get_symbol_class (symtab_node node)
else if (!cgraph (node)->analyzed) else if (!cgraph (node)->analyzed)
return SYMBOL_EXTERNAL; return SYMBOL_EXTERNAL;
/* Weakref aliases are always duplicated. */
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
return SYMBOL_DUPLICATE;
/* Comdats are duplicated to every use unless they are keyed. /* Comdats are duplicated to every use unless they are keyed.
Those do not need duplication. */ Those do not need duplication. */
if (DECL_COMDAT (node->symbol.decl) if (DECL_COMDAT (node->symbol.decl)
...@@ -561,7 +561,8 @@ lto_balanced_map (void) ...@@ -561,7 +561,8 @@ lto_balanced_map (void)
last_visited_node++; last_visited_node++;
gcc_assert (node->analyzed); gcc_assert (node->analyzed
|| lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)));
/* Compute boundary cost of callgraph edges. */ /* Compute boundary cost of callgraph edges. */
for (edge = node->callees; edge; edge = edge->next_callee) for (edge = node->callees; edge; edge = edge->next_callee)
...@@ -768,7 +769,6 @@ privatize_symbol_name (symtab_node node) ...@@ -768,7 +769,6 @@ privatize_symbol_name (symtab_node node)
{ {
tree decl = node->symbol.decl; tree decl = node->symbol.decl;
const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
char *label;
/* Our renaming machinery do not handle more than one change of assembler name. /* Our renaming machinery do not handle more than one change of assembler name.
We should not need more than one anyway. */ We should not need more than one anyway. */
...@@ -793,7 +793,6 @@ privatize_symbol_name (symtab_node node) ...@@ -793,7 +793,6 @@ privatize_symbol_name (symtab_node node)
name); name);
return; return;
} }
ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
change_decl_assembler_name (decl, clone_function_name (decl, "lto_priv")); change_decl_assembler_name (decl, clone_function_name (decl, "lto_priv"));
if (node->symbol.lto_file_data) if (node->symbol.lto_file_data)
lto_record_renamed_decl (node->symbol.lto_file_data, name, lto_record_renamed_decl (node->symbol.lto_file_data, name,
...@@ -869,7 +868,8 @@ rename_statics (lto_symtab_encoder_t encoder, symtab_node node) ...@@ -869,7 +868,8 @@ rename_statics (lto_symtab_encoder_t encoder, symtab_node node)
once this is fixed. */ once this is fixed. */
|| DECL_EXTERNAL (node->symbol.decl) || DECL_EXTERNAL (node->symbol.decl)
|| !symtab_real_symbol_p (node)) || !symtab_real_symbol_p (node))
&& !may_need_named_section_p (encoder, node)) && !may_need_named_section_p (encoder, node)
&& !lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
return; return;
/* Now walk symbols sharing the same name and see if there are any conflicts. /* Now walk symbols sharing the same name and see if there are any conflicts.
...@@ -894,9 +894,11 @@ rename_statics (lto_symtab_encoder_t encoder, symtab_node node) ...@@ -894,9 +894,11 @@ rename_statics (lto_symtab_encoder_t encoder, symtab_node node)
/* Assign every symbol in the set that shares the same ASM name an unique /* Assign every symbol in the set that shares the same ASM name an unique
mangled name. */ mangled name. */
for (s = symtab_node_for_asm (name); s;) for (s = symtab_node_for_asm (name); s;)
if (!s->symbol.externally_visible if ((!s->symbol.externally_visible
|| lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
&& ((symtab_real_symbol_p (s) && ((symtab_real_symbol_p (s)
&& !DECL_EXTERNAL (node->symbol.decl) && (!DECL_EXTERNAL (node->symbol.decl)
|| lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
&& !TREE_PUBLIC (node->symbol.decl)) && !TREE_PUBLIC (node->symbol.decl))
|| may_need_named_section_p (encoder, s)) || may_need_named_section_p (encoder, s))
&& (!encoder && (!encoder
......
2013-05-15 Jan Hubicka <jh@suse.cz>
* gcc.dg/lto/attr-weakref-1_0.c: New testcase.
* gcc.dg/lto/attr-weakref-1_1.c: New testcase.
* gcc.dg/lto/attr-weakref-1_2.c: New testcase.
2013-05-14 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> 2013-05-14 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
* gcc.dg/torture/alias-1.c: Add dg-require-effective-target * gcc.dg/torture/alias-1.c: Add dg-require-effective-target
......
// { dg-do compile }
/* Reduced from libstdc++-v3/testsuite/25_algorithms/equal/1.cc /* Reduced from libstdc++-v3/testsuite/25_algorithms/equal/1.cc
1.2.ii: In function 'void test1()': 1.2.ii: In function 'void test1()':
......
/* { dg-lto-do run } */
int first = 0;
void abort (void);
int second = 0;
void callmealias (void)
{
if (!first || !second)
abort ();
}
void callmefirst (void)
{
if (first)
abort();
first = 1;
}
void callmesecond (void)
{
if (!first)
abort();
if (second)
abort();
second = 1;
}
main()
{
c();
b();
return 0;
}
extern void callmesecond();
static void callmealias() __attribute__((weakref ("callmesecond")));
b()
{
callmealias();
}
extern void callmefirst();
static void callmealias() __attribute__((weakref ("callmefirst")));
c()
{
callmealias();
}
...@@ -86,6 +86,10 @@ dump_varpool_node (FILE *f, struct varpool_node *node) ...@@ -86,6 +86,10 @@ dump_varpool_node (FILE *f, struct varpool_node *node)
fprintf (f, " finalized"); fprintf (f, " finalized");
if (node->output) if (node->output)
fprintf (f, " output"); fprintf (f, " output");
if (TREE_READONLY (node->symbol.decl))
fprintf (f, " read-only");
if (const_value_known_p (node->symbol.decl))
fprintf (f, " const-value-known");
fprintf (f, "\n"); fprintf (f, "\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment