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]

Fix LTO support for compound literals


Hi,
compount literals are constructed COMDAT but not PUBLIC by C frontned.
A while ago I discussed with with Jason? (I believe) and the reason for that
is that they allow sharing even if it is not done by linker.
This however breaks our partitioning code that assumes that COMDAT is always
exported. This patch sives it and fixes one of two problems seen while linking
Linux kernel.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

	* ipa.c (cgraph_externally_visible_p, varpool_externally_visible_p):
	Local comdats are not externally visible.
	* symtab.c (dump_symtab_base): Dump externally visible.
	(verify_symtab_base): Verify back links in the symtab hash.
Index: ipa.c
===================================================================
--- ipa.c	(revision 200016)
+++ ipa.c	(working copy)
@@ -606,9 +606,8 @@ cgraph_externally_visible_p (struct cgra
 {
   if (!node->symbol.definition)
     return false;
-  if (!DECL_COMDAT (node->symbol.decl)
-      && (!TREE_PUBLIC (node->symbol.decl)
-	  || DECL_EXTERNAL (node->symbol.decl)))
+  if (!TREE_PUBLIC (node->symbol.decl)
+      || DECL_EXTERNAL (node->symbol.decl))
     return false;
 
   /* Do not try to localize built-in functions yet.  One of problems is that we
@@ -667,7 +666,7 @@ varpool_externally_visible_p (struct var
   if (DECL_EXTERNAL (vnode->symbol.decl))
     return true;
 
-  if (!DECL_COMDAT (vnode->symbol.decl) && !TREE_PUBLIC (vnode->symbol.decl))
+  if (!TREE_PUBLIC (vnode->symbol.decl))
     return false;
 
   /* If linker counts on us, we must preserve the function.  */
Index: symtab.c
===================================================================
--- symtab.c	(revision 200018)
+++ symtab.c	(working copy)
@@ -508,6 +508,8 @@ dump_symtab_base (FILE *f, symtab_node n
     fprintf (f, " force_output");
   if (node->symbol.forced_by_abi)
     fprintf (f, " forced_by_abi");
+  if (node->symbol.externally_visible)
+    fprintf (f, " externally_visible");
   if (node->symbol.resolution != LDPR_UNKNOWN)
     fprintf (f, " %s",
  	     ld_plugin_symbol_resolution_names[(int)node->symbol.resolution]);
@@ -655,6 +657,15 @@ verify_symtab_base (symtab_node node)
 	  error ("node not found in symtab decl hashtable");
 	  error_found = true;
 	}
+      if (hashed_node != node
+	  && (!is_a <cgraph_node> (node)
+	      || !dyn_cast <cgraph_node> (node)->clone_of
+	      || dyn_cast <cgraph_node> (node)->clone_of->symbol.decl
+		 != node->symbol.decl))
+	{
+	  error ("node differs from symtab decl hashtable");
+	  error_found = true;
+	}
     }
   if (assembler_name_hash)
     {


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