OSDN Git Service

PR c++/48873
[pf3gnuchains/gcc-fork.git] / gcc / lto-symtab.c
index f18b322..28a3d8b 100644 (file)
@@ -25,7 +25,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "gimple.h"
 #include "ggc.h"
-#include "lambda.h"    /* gcd */
 #include "hashtab.h"
 #include "plugin-api.h"
 #include "lto-streamer.h"
@@ -274,7 +273,6 @@ lto_cgraph_replace_node (struct cgraph_node *node,
          last = alias;
          gcc_assert (alias->same_body_alias);
          alias->same_body = prevailing_node;
-         alias->thunk.alias = prevailing_node->decl;
        }
       last->next = prevailing_node->same_body;
       /* Node with aliases is prevailed by alias.
@@ -795,9 +793,26 @@ lto_symtab_merge_cgraph_nodes_1 (void **slot, void *data ATTRIBUTE_UNUSED)
   for (e = prevailing->next; e; e = e->next)
     {
       if (e->node != NULL)
-       lto_cgraph_replace_node (e->node, prevailing->node);
+       {
+         /* In case we prevail funcion by an alias, we can run into case
+            that the alias has no cgraph node attached, since it was
+            previously unused.  Create the node.  */
+         if (!prevailing->node)
+           {
+             prevailing->node = cgraph_create_node (prevailing->decl);
+             prevailing->node->alias = true;
+           }
+         lto_cgraph_replace_node (e->node, prevailing->node);
+       }
       if (e->vnode != NULL)
-       lto_varpool_replace_node (e->vnode, prevailing->vnode);
+       {
+         if (!prevailing->vnode)
+           {
+             prevailing->vnode = varpool_node (prevailing->decl);
+             prevailing->vnode->alias = true;
+           }
+         lto_varpool_replace_node (e->vnode, prevailing->vnode);
+       }
     }
 
   /* Drop all but the prevailing decl from the symtab.  */
@@ -812,8 +827,16 @@ lto_symtab_merge_cgraph_nodes_1 (void **slot, void *data ATTRIBUTE_UNUSED)
 void
 lto_symtab_merge_cgraph_nodes (void)
 {
+  struct cgraph_node *node, *alias, *next;
   lto_symtab_maybe_init_hash_table ();
   htab_traverse (lto_symtab_identifiers, lto_symtab_merge_cgraph_nodes_1, NULL);
+
+  for (node = cgraph_nodes; node; node = node->next)
+    for (alias = node->same_body; alias; alias = next)
+      {
+       next = alias->next;
+       alias->thunk.alias = lto_symtab_prevailing_decl (alias->thunk.alias);
+      }
 }
 
 /* Given the decl DECL, return the prevailing decl with the same name. */