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 undefined symbol references with -fwhopr


Hi,
this patch fixes undefined symbols problems seen when compiling DLV with WHOR.
The problem is that we do not track who is taking address of what and thus
we have no idea how we spread references to symbols across the partitions.

This disables optimization removing unused global variables, but we still
can do so for statics before streaming.  We can fix this later by collecting
the references into callgraph.

Bootstrapped/regtested x86_64-linux, will commit it as obvoius.

Honza

	* lto.c (globalize_cross_file_statics): When function has address taken,
	it needs to be public.
	* varpool.c (decide_is_variable_needed): Variable is always needed
	during ltrans.
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 158563)
+++ lto/lto.c	(working copy)
@@ -760,7 +760,8 @@ globalize_cross_file_statics (tree *tp, 
     }
   else if (TREE_CODE (t) == FUNCTION_DECL && !TREE_PUBLIC (t))
     {
-      if (!cgraph_node_in_set_p (cgraph_node (t), context->set))
+      if (!cgraph_node_in_set_p (cgraph_node (t), context->set)
+	  || cgraph_node (t)->address_taken)
 	{
 	  /* This file-scope static function is reachable from a set
 	     which does not contain the function DECL.  Make it global
Index: varpool.c
===================================================================
--- varpool.c	(revision 158563)
+++ varpool.c	(working copy)
@@ -230,6 +230,12 @@ varpool_reset_queue (void)
 bool
 decide_is_variable_needed (struct varpool_node *node, tree decl)
 {
+  /* We do not track variable references at all and thus have no idea if the
+     variable was referenced in some other partition or not.  
+     FIXME: We really need address taken edges in callgraph and varpool to
+     drive WPA and decide whether other partition might reference it or not.  */
+  if (flag_ltrans)
+    return true;
   /* If the user told us it is used, then it must be so.  */
   if ((node->externally_visible && !DECL_COMDAT (decl))
       || node->force_output)


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