@@ -2430,16 +2430,6 @@ symbol_table::finalize_compilation_unit (void)
if (flag_dump_passes)
dump_passes ();
- /* Generate early debug for global symbols. Any local symbols will
- be handled by either handling reachable functions further down
- (and by consequence, locally scoped symbols), or by generating
- DIEs for types. */
- symtab_node *snode;
- FOR_EACH_SYMBOL (snode)
- if (TREE_CODE (snode->decl) != FUNCTION_DECL
- && !decl_function_context (snode->decl))
- (*debug_hooks->early_global_decl) (snode->decl);
-
/* Gimplify and lower all functions, compute reachability and
remove unreachable nodes. */
analyze_functions ();
@@ -21868,17 +21868,6 @@ dwarf2out_decl (tree decl)
break;
case VAR_DECL:
- /* Ignore this VAR_DECL if it refers to a file-scope extern data object
- declaration and if the declaration was never even referenced from
- within this entire compilation unit. We suppress these DIEs in
- order to save space in the .debug section (by eliminating entries
- which are probably useless). Note that we must not suppress
- block-local extern declarations (whether used or not) because that
- would screw-up the debugger's name lookup mechanism and cause it to
- miss things which really ought to be in scope at a given point. */
- if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
- return NULL;
-
/* For local statics lookup proper context die. */
if (local_function_static (decl))
context_die = lookup_decl_die (DECL_CONTEXT (decl));
@@ -25110,6 +25099,8 @@ dwarf2out_finish (const char *filename)
if (flag_eliminate_unused_debug_types)
prune_unused_types ();
+ /* FIXME: Prune DIEs for unused decls. */
+
/* Generate separate COMDAT sections for type DIEs. */
if (use_debug_types)
{
@@ -293,11 +293,16 @@ rest_of_decl_compilation (tree decl,
&& TREE_STATIC (decl))
varpool_node::get_create (decl);
- /* ?? Theoretically, we should be able to to call
- debug_hooks->early_global_decl() here just as we do for
- rest_of_type_compilation below. This would require changing how
- we're currently calling early_global_decl() in all the
- front-ends. Something to look into later. */
+ /* Generate early debug for global symbols. Any local symbols will
+ be handled by either handling reachable functions from
+ finalize_compilation_unit (and by consequence, locally scoped
+ symbols), or by rest_of_type_compilation below. */
+ if (!flag_wpa
+ && TREE_CODE (decl) != FUNCTION_DECL
+ && !decl_function_context (decl)
+ && !current_function_decl
+ && !decl_type_context (decl))
+ (*debug_hooks->early_global_decl) (decl);
}
/* Called after finishing a record, union or enumeral type. */