PR middle-end/PR30700
authorJan Hubicka <jh@suse.cz>
Fri, 30 Mar 2007 08:03:55 +0000 (10:03 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 30 Mar 2007 08:03:55 +0000 (08:03 +0000)
PR middle-end/PR30700
* dwarf2out.c (reference_to_unused): Ask cgraph for functions
availablility; add more sanity checking; ask varpool only about
VAR_DECL.

From-SVN: r123358

gcc/ChangeLog
gcc/dwarf2out.c

index 31cddc01829a55257fc61fc49a99ce0a17988ab6..ffb6de486fae27ac3b1e81930bcd84774ab1415b 100644 (file)
@@ -1,3 +1,10 @@
+2007-03-30  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/PR30700
+       * dwarf2out.c (reference_to_unused): Ask cgraph for functions 
+       availablility; add more sanity checking; ask varpool only about
+       VAR_DECL.
+
 2007-03-29  Richard Henderson  <rth@redhat.com>
 
        * unwind-generic.h (_sleb128_t, _uleb128_t): Don't use HAVE_LONG_LONG
index fa00452e594efe0ad09bb6fded911bf8ce423082..57c8617a1f209b4dab26830cb7354e755edf3cab 100644 (file)
@@ -10121,12 +10121,24 @@ reference_to_unused (tree * tp, int * walk_subtrees,
   if (DECL_P (*tp) && ! TREE_PUBLIC (*tp) && ! TREE_USED (*tp)
       && ! TREE_ASM_WRITTEN (*tp))
     return *tp;
-  else if (DECL_P (*tp) && TREE_CODE (*tp) != FUNCTION_DECL)
+  else if (!flag_unit_at_a_time)
+    return NULL_TREE;
+  else if (!cgraph_global_info_ready
+          && (TREE_CODE (*tp) == VAR_DECL || TREE_CODE (*tp) == FUNCTION_DECL))
+    gcc_unreachable ();
+  else if (DECL_P (*tp) && TREE_CODE (*tp) == VAR_DECL)
     {
       struct varpool_node *node = varpool_node (*tp);
       if (!node->needed)
        return *tp;
     }
+  else if (DECL_P (*tp) && TREE_CODE (*tp) == FUNCTION_DECL
+          && (!DECL_EXTERNAL (*tp) || DECL_DECLARED_INLINE_P (*tp)))
+    {
+      struct cgraph_node *node = cgraph_node (*tp);
+      if (!node->output)
+        return *tp;
+    }
 
   return NULL_TREE;
 }