This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix undefined symbol references with -fwhopr
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org, dnovillo at google dot com, rguenther at suse dot de
- Date: Tue, 20 Apr 2010 22:46:15 +0200
- Subject: 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)