This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Transparent alias suport part 2 (lto-partition fixes)


Hi,
this patch fixes lto-partition WRT transparent aliases.  Normal aliases are
always put to the same partition as their target and in other partitions
they become part of the boundary (so we know that the two symbols are in fact
equivalent).

Weakrefs and transparent aliases go only into the partitions that use them.

Other issue is that while promoting a symbol to hidden you in fact also promote
all transparent aliases.

Bootstrapped/regtested x86_64-linux, will commit it shortly.
Honza
	* lto-partition.c (add_symbol_to_partition_1): Transparent aliases
	are not part of the definition.
	(contained_in_symbol): Likewise.
	(promote_symbol): When promoting a symbol also promote all transparent
	aliases.
	(rename_statics): Weakref needs unique name, too.
Index: lto/lto-partition.c
===================================================================
--- lto/lto-partition.c	(revision 231376)
+++ lto/lto-partition.c	(working copy)
@@ -177,8 +177,20 @@ add_symbol_to_partition_1 (ltrans_partit
   /* Add all aliases associated with the symbol.  */
 
   FOR_EACH_ALIAS (node, ref)
-    if (!node->weakref)
+    if (!ref->referring->transparent_alias)
       add_symbol_to_partition_1 (part, ref->referring);
+    else
+      {
+	struct ipa_ref *ref2;
+	/* We do not need to add transparent aliases if they are not used.
+	   However we must add aliases of transparent aliases if they exist.  */
+	FOR_EACH_ALIAS (ref->referring, ref2)
+	  {
+	    /* Nested transparent aliases are not permitted.  */
+	    gcc_checking_assert (!ref2->referring->transparent_alias);
+	    add_symbol_to_partition_1 (part, ref2->referring);
+	  }
+      }
 
   /* Ensure that SAME_COMDAT_GROUP lists all allways added in a group.  */
   if (node->same_comdat_group)
@@ -199,8 +211,10 @@ add_symbol_to_partition_1 (ltrans_partit
 static symtab_node *
 contained_in_symbol (symtab_node *node)
 {
-  /* Weakrefs are never contained in anything.  */
-  if (node->weakref)
+  /* There is no need to consider transparent aliases to be part of the
+     definition: they are only useful insite the partition they are output
+     and thus we will always see an explicit reference to it.  */
+  if (node->transparent_alias)
     return node;
   if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
     {
@@ -967,6 +981,23 @@ promote_symbol (symtab_node *node)
   TREE_PUBLIC (node->decl) = 1;
   DECL_VISIBILITY (node->decl) = VISIBILITY_HIDDEN;
   DECL_VISIBILITY_SPECIFIED (node->decl) = true;
+  ipa_ref *ref;
+
+  /* Promoting a symbol also promotes all trasparent aliases with exception
+     of weakref where the visibility flags are always wrong and set to 
+     !PUBLIC.  */
+  for (unsigned i = 0; node->iterate_direct_aliases (i, ref); i++)
+    {
+      struct symtab_node *alias = ref->referring;
+      if (alias->transparent_alias && !alias->weakref)
+	{
+	  TREE_PUBLIC (alias->decl) = 1;
+	  DECL_VISIBILITY (alias->decl) = VISIBILITY_HIDDEN;
+	  DECL_VISIBILITY_SPECIFIED (alias->decl) = true;
+	}
+      gcc_assert (!alias->weakref || TREE_PUBLIC (alias->decl));
+    }
+
   if (symtab->dump_file)
     fprintf (symtab->dump_file,
 	    "Promoting as hidden: %s\n", node->name ());
@@ -974,7 +1005,8 @@ promote_symbol (symtab_node *node)
 
 /* Return true if NODE needs named section even if it won't land in the partition
    symbol table.
-   FIXME: we should really not use named sections for inline clones and master clones.  */
+   FIXME: we should really not use named sections for inline clones and master
+   clones.  */
 
 static bool
 may_need_named_section_p (lto_symtab_encoder_t encoder, symtab_node *node)
@@ -1004,7 +1036,7 @@ rename_statics (lto_symtab_encoder_t enc
   tree name = DECL_ASSEMBLER_NAME (decl);
 
   /* See if this is static symbol. */
-  if ((node->externally_visible
+  if (((node->externally_visible && !node->weakref)
       /* FIXME: externally_visible is somewhat illogically not set for
 	 external symbols (i.e. those not defined).  Remove this test
 	 once this is fixed.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]