re PR middle-end/41729 (Undefined reference with -fPIC -fwhole-program -flto)
authorJan Hubicka <jh@suse.cz>
Wed, 11 Nov 2009 23:45:09 +0000 (00:45 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 11 Nov 2009 23:45:09 +0000 (23:45 +0000)
PR middle-end/41729
* ipa.c (function_and_variable_visibility): Do not privatize COMDAT
and WEAK variables at -fwhole-program.

PR middle-end/41735
* ipa.c (whole_program_function_and_variable_visility): COMDAT
functions/variables are not needed even if they are externally visible.

From-SVN: r154108

gcc/ChangeLog
gcc/ipa.c

index 3e4d5be..8c9e6e5 100644 (file)
@@ -1,5 +1,15 @@
 2009-11-11  Jan Hubicka  <jh@suse.cz>
 
+       PR middle-end/41729
+       * ipa.c (function_and_variable_visibility): Do not privatize COMDAT
+       and WEAK variables at -fwhole-program.
+
+       PR middle-end/41735
+       * ipa.c (whole_program_function_and_variable_visility): COMDAT
+       functions/variables are not needed even if they are externally visible.
+
+2009-11-11  Jan Hubicka  <jh@suse.cz>
+
        (patch by Richard Guenther)
        * lto-streamer-out.c (output_function): Output head of argument list
        earlier.
index b082efe..1e5f22c 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -319,6 +319,11 @@ function_and_variable_visibility (bool whole_program)
       if (vnode->needed
          && (DECL_COMDAT (vnode->decl) || TREE_PUBLIC (vnode->decl))
          && (!whole_program
+             /* We can privatize comdat readonly variables whose address is not taken,
+                but doing so is not going to bring us optimization oppurtunities until
+                we start reordering datastructures.  */
+             || DECL_COMDAT (vnode->decl)
+             || DECL_WEAK (vnode->decl)
              || lookup_attribute ("externally_visible",
                                   DECL_ATTRIBUTES (vnode->decl))))
        vnode->externally_visible = true;
@@ -396,10 +401,11 @@ whole_program_function_and_variable_visibility (void)
   function_and_variable_visibility (flag_whole_program);
 
   for (node = cgraph_nodes; node; node = node->next)
-    if (node->local.externally_visible && node->local.finalized)
+    if ((node->local.externally_visible && !DECL_COMDAT (node->decl))
+        && node->local.finalized)
       cgraph_mark_needed_node (node);
   for (vnode = varpool_nodes_queue; vnode; vnode = vnode->next_needed)
-    if (vnode->externally_visible)
+    if (vnode->externally_visible && !DECL_COMDAT (vnode->decl))
       varpool_mark_needed_node (vnode);
   return 0;
 }