OSDN Git Service

PR lto/46940
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2010 23:22:23 +0000 (23:22 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2010 23:22:23 +0000 (23:22 +0000)
PR lto/44463
* lto-symtab.c (lto_symtab_merge_cgraph_nodes_1): Construct nodes
for aliases when they are used.

* gcc.dg/lto/pr46940_0.c: New testcase.
* gcc.dg/lto/pr46940_1.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167822 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/lto-symtab.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/pr46940_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr46940_1.c [new file with mode: 0644]

index 91b9b22..f2c7b5c 100644 (file)
@@ -1,3 +1,10 @@
+2010-12-14  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/46940
+       PR lto/44463
+       * lto-symtab.c (lto_symtab_merge_cgraph_nodes_1): Construct nodes
+       for aliases when they are used.
+
 2010-12-14  Joseph Myers  <joseph@codesourcery.com>
 
        * config.gcc (sparc-*-elf*, sparc-*-rtems*, sparc-*-linux*,
index f18b322..b331d5c 100644 (file)
@@ -795,9 +795,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_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.  */
index 99c8103..f321051 100644 (file)
@@ -1,3 +1,10 @@
+2010-12-14  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/46940
+       PR lto/44463
+       * gcc.dg/lto/pr46940_0.c: New testcase.
+       * gcc.dg/lto/pr46940_1.c: New testcase.
+
 2010-12-14  Nathan Froyd  <froydnj@codesourcery.com>
 
        PR c++/45330
diff --git a/gcc/testsuite/gcc.dg/lto/pr46940_0.c b/gcc/testsuite/gcc.dg/lto/pr46940_0.c
new file mode 100644 (file)
index 0000000..e9f6dc8
--- /dev/null
@@ -0,0 +1,10 @@
+* { dg-require-linker-plugin "" } */
+* { dg-extra-ld-options "-fuse-linker-plugin" } */
+
+extern __attribute__((visibility("hidden"))) void _moz_foo (void);
+extern __typeof (_moz_foo) _moz_foo __asm__ ("" "INT__foo") __attribute__((__visibility__("hidden"))) ;
+void _moz_foo(void)
+{
+  printf ("blah\n");
+}
+extern __typeof (_moz_foo) EXT__foo __asm__("" "_moz_foo") __attribute__((__alias__("" "INT__foo")));
diff --git a/gcc/testsuite/gcc.dg/lto/pr46940_1.c b/gcc/testsuite/gcc.dg/lto/pr46940_1.c
new file mode 100644 (file)
index 0000000..0a8dab5
--- /dev/null
@@ -0,0 +1,5 @@
+extern void _moz_foo (void);
+main()
+{
+  _moz_foo ();
+}