public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Cgraph alias reorg 22/14 (enable new infrastrucure for function-functoin aliases)
@ 2011-06-15 12:54 Jan Hubicka
  2011-06-15 13:07 ` Rainer Orth
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Hubicka @ 2011-06-15 12:54 UTC (permalink / raw)
  To: gcc-patches

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 ----

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Cgraph alias reorg 22/14 (enable new infrastrucure for function-functoin aliases)
  2011-06-15 12:54 Cgraph alias reorg 22/14 (enable new infrastrucure for function-functoin aliases) Jan Hubicka
@ 2011-06-15 13:07 ` Rainer Orth
  0 siblings, 0 replies; 2+ messages in thread
From: Rainer Orth @ 2011-06-15 13:07 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

Jan Hubicka <hubicka@ucw.cz> writes:

> 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.

Please keep in mind that there are assemblers without weakref support
(at least the Solaris and Tru64 UNIX assemblers).

> 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.  */
             ^ typo


Thanks.
	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-15 12:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-15 12:54 Cgraph alias reorg 22/14 (enable new infrastrucure for function-functoin aliases) Jan Hubicka
2011-06-15 13:07 ` Rainer Orth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).