Hi!

I've committed this fix, where cgraph_remove_unreachable_nodes
was clearing vnode->needed for nodes marked as force_output
because something was aliasing them.  For -O1 the varpool nodes
were removed completely (also undesirable), but for -O0 they
were kept around and ICEd because needed wasn't set in them.

Bootstrapped/regtested on x86_64-linux and i686-linux, approved by Honza on
IRC.

2011-03-11  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/48044
        * ipa.c (cgraph_remove_unreachable_nodes): Enqueue
        all vnode->force_output nodes as needed.

        * gcc.dg/torture/pr48044.c: New test.

--- gcc/ipa.c.jj        2011-01-18 12:20:18.000000000 +0100
+++ gcc/ipa.c   2011-03-11 12:27:04.000000000 +0100
@@ -259,7 +259,7 @@ cgraph_remove_unreachable_nodes (bool be
     {
       vnode->next_needed = NULL;
       vnode->prev_needed = NULL;
-      if (vnode->analyzed
+      if ((vnode->analyzed || vnode->force_output)
          && !varpool_can_remove_if_no_refs (vnode))
        {
          vnode->needed = false;
--- gcc/testsuite/gcc.dg/torture/pr48044.c.jj   2011-03-11 12:28:59.000000000 
+0100
+++ gcc/testsuite/gcc.dg/torture/pr48044.c      2011-03-11 12:28:48.000000000 
+0100
@@ -0,0 +1,7 @@
+/* PR middle-end/48044 */
+/* { dg-do compile } */
+/* { dg-require-alias "" } */
+
+int a __asm__ ("b") = 0;
+extern int c __asm__ ("a") __attribute__ ((alias ("b")));
+extern int d __attribute__ ((weak, alias ("a")));

        Jakub

Reply via email to