Hi,
this patch switch regular function-function aliases to the new representation.
I plan to followup with reorg of weakrefs and variable-variable aliases and then
remove the infrastructure for aliases. It is however better to do these step by
step so possible problems are easier to track.
Bootstrapped/regtested x86_64-linux and also tested on Mozilla that uses quite
some aliases.
Honza
* cgraphunit.c (handle_alias_pairs): New function.
(cgraph_finalize_compilation_unit): Use it.
* ipa.c (cgraph_externally_visible_p): Remove hack marking asm names
as externally visible.
Index: cgraphunit.c
===
*** cgraphunit.c(revision 175078)
--- cgraphunit.c(working copy)
*** cgraph_analyze_functions (void)
*** 1175,1180
--- 1175,1223
ggc_collect ();
}
+ /* Translate the ugly representation of aliases as alias pairs into nice
+representation in callgraph. We don't handle all cases yet,
+unforutnately. */
+
+ static void
+ handle_alias_pairs (void)
+ {
+ alias_pair *p;
+ unsigned i;
+ struct cgraph_node *target_node;
+ struct cgraph_node *src_node;
+
+ for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p);)
+ {
+ if (TREE_CODE (p->decl) == FUNCTION_DECL
+ && !lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl))
+ && (target_node = cgraph_node_for_asm (p->target)) != NULL)
+ {
+ src_node = cgraph_get_node (p->decl);
+ if (src_node && src_node->local.finalized)
+ cgraph_reset_node (src_node);
+ /* Normally EXTERNAL flag is used to mark external inlines,
+however for aliases it seems to be allowed to use it w/o
+any meaning. See gcc.dg/attr-alias-3.c
+However for weakref we insist on EXTERNAL flag being set.
+See gcc.dg/attr-alias-5.c */
+ if (DECL_EXTERNAL (p->decl))
+ DECL_EXTERNAL (p->decl) = 0;
+ cgraph_create_function_alias (p->decl, target_node->decl);
+ VEC_unordered_remove (alias_pair, alias_pairs, i);
+ }
+ else
+ {
+ if (dump_file)
+ fprintf (dump_file, "Unhandled alias %s->%s\n",
+IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (p->decl)),
+IDENTIFIER_POINTER (p->target));
+
+ i++;
+ }
+ }
+ }
+
/* Analyze the whole compilation unit once it is parsed completely. */
*** cgraph_finalize_compilation_unit (void)
*** 1200,1205
--- 1243,1249
/* Mark alias targets necessary and emit diagnostics. */
finish_aliases_1 ();
+ handle_alias_pairs ();
if (!quiet_flag)
{
*** cgraph_finalize_compilation_unit (void)
*** 1216,1221
--- 1260,1266
/* Mark alias targets necessary and emit diagnostics. */
finish_aliases_1 ();
+ handle_alias_pairs ();
/* Gimplify and lower thunks. */
cgraph_analyze_functions ();
Index: ipa.c
===
*** ipa.c (revision 175078)
--- ipa.c (working copy)
*** cgraph_externally_visible_p (struct cgra
*** 612,625
if (DECL_BUILT_IN (node->decl))
return true;
- /* FIXME: We get wrong symbols with asm aliases in callgraph and LTO.
- This is because very little of code knows that assembler name needs to
- mangled. Avoid touching declarations with user asm name set to mask
- some of the problems. */
- if (DECL_ASSEMBLER_NAME_SET_P (node->decl)
- && IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl))[0]=='*')
- return true;
-
/* If linker counts on us, we must preserve the function. */
if (cgraph_used_from_object_file_p (node))
return true;
--- 612,617