]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
varpool.c: Include pointer-set.h.
authorJan Hubicka <hubicka@ucw.cz>
Fri, 7 Feb 2014 23:49:18 +0000 (00:49 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 7 Feb 2014 23:49:18 +0000 (23:49 +0000)
* varpool.c: Include pointer-set.h.
(varpool_remove_unreferenced_decls): Variables in other partitions
will not be output; be however careful to not lose information
about partitioning.

From-SVN: r207620

gcc/ChangeLog
gcc/varpool.c

index a0ae1882316d3f8566e82bb175bb848ed2c8640d..b69091eec05344d07ee317f4f4fb791ee19e11d0 100644 (file)
@@ -1,3 +1,10 @@
+2014-02-07  Jan Hubicka  <hubicka@ucw.cz>
+
+       * varpool.c: Include pointer-set.h.
+       (varpool_remove_unreferenced_decls): Variables in other partitions
+       will not be output; be however careful to not lose information
+       about partitioning.
+
 2014-02-07  Jan Hubicka  <hubicka@ucw.cz>
 
        * gimple-fold.c (gimple_get_virt_method_for_vtable): Do O(1)
index 54570343e0ad3087b44bb47e9b0f1c4fd00c604d..acb522100ea96a9a4819a43c66014d49e84c1d6f 100644 (file)
@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "output.h"
 #include "gimple-expr.h"
 #include "flags.h"
+#include "pointer-set.h"
 
 /* List of hooks triggered on varpool_node events.  */
 struct varpool_node_hook_list {
@@ -262,7 +263,7 @@ ctor_for_folding (tree decl)
     return error_mark_node;
 
   /* Do not care about automatic variables.  Those are never initialized
-     anyway, because gimplifier exapnds the code*/
+     anyway, because gimplifier exapnds the code.  */
   if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
     {
       gcc_assert (!TREE_PUBLIC (decl));
@@ -486,6 +487,7 @@ varpool_remove_unreferenced_decls (void)
   varpool_node *first = (varpool_node *)(void *)1;
   int i;
   struct ipa_ref *ref;
+  struct pointer_set_t *referenced = pointer_set_create ();
 
   if (seen_error ())
     return;
@@ -518,7 +520,7 @@ varpool_remove_unreferenced_decls (void)
               next = next->same_comdat_group)
            {
              varpool_node *vnext = dyn_cast <varpool_node> (next);
-             if (vnext && vnext->analyzed)
+             if (vnext && vnext->analyzed && !symtab_comdat_local_p (next))
                enqueue_node (vnext, &first);
            }
        }
@@ -526,10 +528,13 @@ varpool_remove_unreferenced_decls (void)
        {
          varpool_node *vnode = dyn_cast <varpool_node> (ref->referred);
          if (vnode
+             && !vnode->in_other_partition
              && (!DECL_EXTERNAL (ref->referred->decl)
                  || vnode->alias)
              && vnode->analyzed)
            enqueue_node (vnode, &first);
+         else
+           pointer_set_insert (referenced, node);
        }
     }
   if (cgraph_dump_file)
@@ -541,9 +546,13 @@ varpool_remove_unreferenced_decls (void)
        {
           if (cgraph_dump_file)
            fprintf (cgraph_dump_file, " %s", node->asm_name ());
-         varpool_remove_node (node);
+         if (pointer_set_contains (referenced, node))
+           varpool_remove_initializer (node);
+         else
+           varpool_remove_node (node);
        }
     }
+  pointer_set_destroy (referenced);
   if (cgraph_dump_file)
     fprintf (cgraph_dump_file, "\n");
 }