OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / dbxout.c
index 5ed9b69..8c59b45 100644 (file)
@@ -88,35 +88,16 @@ along with GCC; see the file COPYING3.  If not see
 #include "debug.h"
 #include "function.h"
 #include "target.h"
+#include "common/common-target.h"
 #include "langhooks.h"
 #include "obstack.h"
 #include "expr.h"
+#include "cgraph.h"
 
 #ifdef XCOFF_DEBUGGING_INFO
 #include "xcoffout.h"
 #endif
 
-/* When -gused is used, emit debug info for only used symbols. But in
-   addition to the standard intercepted debug_hooks there are some
-   direct calls into this file, i.e., dbxout_symbol, dbxout_parms, and
-   dbxout_reg_params.  Those routines may also be called from a higher
-   level intercepted routine. So to prevent recording data for an inner
-   call to one of these for an intercept, we maintain an intercept
-   nesting counter (debug_nesting). We only save the intercepted
-   arguments if the nesting is 1.  */
-static int debug_nesting = 0;
-
-static tree *symbol_queue;
-static int symbol_queue_index = 0;
-static int symbol_queue_size = 0;
-
-#define DBXOUT_DECR_NESTING \
-  if (--debug_nesting == 0 && symbol_queue_index > 0) \
-    { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
-
-#define DBXOUT_DECR_NESTING_AND_RETURN(x) \
-  do {--debug_nesting; return (x);} while (0)
-
 #ifndef ASM_STABS_OP
 # ifdef XCOFF_DEBUGGING_INFO
 #  define ASM_STABS_OP "\t.stabx\t"
@@ -924,6 +905,31 @@ dbxout_finish_complex_stabs (tree sym, stab_code_type code,
   obstack_free (&stabstr_ob, str);
 }
 
+#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
+
+/* When -gused is used, emit debug info for only used symbols. But in
+   addition to the standard intercepted debug_hooks there are some
+   direct calls into this file, i.e., dbxout_symbol, dbxout_parms, and
+   dbxout_reg_params.  Those routines may also be called from a higher
+   level intercepted routine. So to prevent recording data for an inner
+   call to one of these for an intercept, we maintain an intercept
+   nesting counter (debug_nesting). We only save the intercepted
+   arguments if the nesting is 1.  */
+static int debug_nesting = 0;
+
+static tree *symbol_queue;
+static int symbol_queue_index = 0;
+static int symbol_queue_size = 0;
+
+#define DBXOUT_DECR_NESTING \
+  if (--debug_nesting == 0 && symbol_queue_index > 0) \
+    { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
+
+#define DBXOUT_DECR_NESTING_AND_RETURN(x) \
+  do {--debug_nesting; return (x);} while (0)
+
+#endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
+
 #if defined (DBX_DEBUGGING_INFO)
 
 static void
@@ -946,7 +952,7 @@ dbxout_function_end (tree decl ATTRIBUTE_UNUSED)
      named sections.  */
   if (!use_gnu_debug_info_extensions
       || NO_DBX_FUNCTION_END
-      || !targetm.have_named_sections)
+      || !targetm_common.have_named_sections)
     return;
 
   /* By convention, GCC will mark the end of a function with an N_FUN
@@ -1505,7 +1511,7 @@ dbxout_type_fields (tree type)
     {
       /* If one of the nodes is an error_mark or its type is then
         return early.  */
-      if (tem == error_mark_node || TREE_TYPE (tem) == error_mark_node)
+      if (error_operand_p (tem))
        return;
 
       /* Omit here local type decls until we know how to support them.  */
@@ -2466,6 +2472,20 @@ dbxout_expand_expr (tree expr)
         disable debug info for these variables.  */
       if (!targetm.have_tls && DECL_THREAD_LOCAL_P (expr))
        return NULL;
+      if (TREE_STATIC (expr)
+         && !TREE_ASM_WRITTEN (expr)
+         && !DECL_HAS_VALUE_EXPR_P (expr)
+         && !TREE_PUBLIC (expr)
+         && DECL_RTL_SET_P (expr)
+         && MEM_P (DECL_RTL (expr)))
+       {
+         /* If this is a var that might not be actually output,
+            return NULL, otherwise stabs might reference an undefined
+            symbol.  */
+         struct varpool_node *node = varpool_get_node (expr);
+         if (!node || !node->needed)
+           return NULL;
+       }
       /* FALLTHRU */
 
     case PARM_DECL: