aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorJohan Karlsson <johan.karlsson@enea.com>2019-03-25 21:19:09 +0000
committerJeff Law <law@gcc.gnu.org>2019-03-25 15:19:09 -0600
commit715e3349b08decc26a5590a017e85dcf761b0de8 (patch)
tree8adb95f6f51f4871997545830de9c9c7f9243b51 /gcc/dwarf2out.c
parent33163a622d9f334e862078419782e3d967bb3db3 (diff)
downloadgcc-715e3349b08decc26a5590a017e85dcf761b0de8.zip
gcc-715e3349b08decc26a5590a017e85dcf761b0de8.tar.gz
gcc-715e3349b08decc26a5590a017e85dcf761b0de8.tar.bz2
re PR debug/86964 (Too many debug symbols included, especially for extern globals)
PR debug/86964 * dwarf2out.c (premark_used_variables): New function. (prune_unused_types_walk): Do not mark not premarked external variables. (prune_unused_types): Call premark_used_variables. * gcc.dg/debug/dwarf2/pr86964.c: New testcase. From-SVN: r269925
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ae8bdee..b9a624e 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -22732,6 +22732,21 @@ premark_types_used_by_global_vars (void)
->traverse<void *, premark_types_used_by_global_vars_helper> (NULL);
}
+/* Mark all variables used by the symtab as perennial. */
+
+static void
+premark_used_variables (void)
+{
+ /* Mark DIEs in the symtab as used. */
+ varpool_node *var;
+ FOR_EACH_VARIABLE (var)
+ {
+ dw_die_ref die = lookup_decl_die (var->decl);
+ if (die)
+ die->die_perennial_p = 1;
+ }
+}
+
/* Generate a DW_TAG_call_site DIE in function DECL under SUBR_DIE
for CA_LOC call arg loc node. */
@@ -29394,6 +29409,19 @@ prune_unused_types_walk (dw_die_ref die)
return;
+ case DW_TAG_variable:
+ if (flag_debug_only_used_symbols)
+ {
+ if (die->die_perennial_p)
+ break;
+
+ /* premark_used_variables marks external variables --- don't mark
+ them here. */
+ if (get_AT (die, DW_AT_external))
+ return;
+ }
+ /* FALLTHROUGH */
+
default:
/* Mark everything else. */
break;
@@ -29520,6 +29548,10 @@ prune_unused_types (void)
/* Mark types that are used in global variables. */
premark_types_used_by_global_vars ();
+ /* Mark variables used in the symtab. */
+ if (flag_debug_only_used_symbols)
+ premark_used_variables ();
+
/* Set the mark on nodes that are actually used. */
prune_unused_types_walk (comp_unit_die ());
for (node = limbo_die_list; node; node = node->next)