aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-09-25 14:51:39 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-09-25 14:51:39 +0000
commit4fb792e189c183aa499e834d9cdc4b3ee3bd064a (patch)
tree843caed21202ecfd5a8d636551059034a18b5bfb /gcc/dwarf2out.c
parentf5ec13f15ddaa6dc61b81d5c14cd8b30df896b40 (diff)
downloadgcc-4fb792e189c183aa499e834d9cdc4b3ee3bd064a.zip
gcc-4fb792e189c183aa499e834d9cdc4b3ee3bd064a.tar.gz
gcc-4fb792e189c183aa499e834d9cdc4b3ee3bd064a.tar.bz2
re PR debug/83941 (Debug info generated with -flto contains useless forwarders)
2018-09-25 Richard Biener <rguenther@suse.de> PR debug/83941 * dwarf2out.c (add_AT_external_die_ref): Remove now redundant GC-ification. (maybe_create_die_with_external_ref): Do not create DW_TAG_imported_unit here. (add_abstract_origin_attribute): Handle external BLOCK refs. (dwarf2out_abstract_function): Simplify LTO case. (dwarf2out_early_finish): Create DW_TAG_imported_unit explicitely rather than using maybe_create_die_with_external_ref. From-SVN: r264573
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 6f45794..1607269 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -5868,7 +5868,7 @@ add_AT_external_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind,
/* ??? We probably want to share these, thus put a ref to the DIE
we create here to the external_die_map entry. */
dw_die_ref ref = new_die_raw (die->die_tag);
- ref->die_id.die_symbol = IDENTIFIER_POINTER (get_identifier (symbol));
+ ref->die_id.die_symbol = symbol;
ref->die_offset = offset;
ref->with_offset = 1;
add_AT_die_ref (die, attr_kind, ref);
@@ -5966,8 +5966,6 @@ maybe_create_die_with_external_ref (tree decl)
case TRANSLATION_UNIT_DECL:
{
die = comp_unit_die ();
- dw_die_ref import = new_die (DW_TAG_imported_unit, die, NULL_TREE);
- add_AT_external_die_ref (import, DW_AT_import, sym, off);
/* We re-target all CU decls to the LTRANS CU DIE, so no need
to create a DIE for the original CUs. */
return die;
@@ -21134,19 +21132,21 @@ add_abstract_origin_attribute (dw_die_ref die, tree origin)
{
dw_die_ref origin_die = NULL;
- if (DECL_P (origin))
+ /* For late LTO debug output we want to refer directly to the abstract
+ DIE in the early debug rather to the possibly existing concrete
+ instance and avoid creating that just for this purpose. */
+ sym_off_pair *desc;
+ if (in_lto_p
+ && external_die_map
+ && (desc = external_die_map->get (origin)))
{
- sym_off_pair *desc;
- if (in_lto_p
- && external_die_map
- && (desc = external_die_map->get (origin)))
- {
- add_AT_external_die_ref (die, DW_AT_abstract_origin,
- desc->sym, desc->off);
- return;
- }
- origin_die = lookup_decl_die (origin);
+ add_AT_external_die_ref (die, DW_AT_abstract_origin,
+ desc->sym, desc->off);
+ return;
}
+
+ if (DECL_P (origin))
+ origin_die = lookup_decl_die (origin);
else if (TYPE_P (origin))
origin_die = lookup_type_die (origin);
else if (TREE_CODE (origin) == BLOCK)
@@ -22458,21 +22458,15 @@ dwarf2out_abstract_function (tree decl)
if (DECL_IGNORED_P (decl))
return;
- /* Do not lazily create a DIE for decl here just because we
- got called via debug_hooks->outlining_inline_function. */
- if (in_lto_p
- && external_die_map
- && external_die_map->get (decl))
+ /* In LTO we're all set. We already created abstract instances
+ early and we want to avoid creating a concrete instance of that
+ if we don't output it. */
+ if (in_lto_p)
return;
old_die = lookup_decl_die (decl);
- /* With early debug we always have an old DIE unless we are in LTO
- and the user did not compile but only link with debug. */
- if (in_lto_p && ! old_die)
- return;
gcc_assert (old_die != NULL);
- if (get_AT (old_die, DW_AT_inline)
- || get_AT (old_die, DW_AT_abstract_origin))
+ if (get_AT (old_die, DW_AT_inline))
/* We've already generated the abstract instance. */
return;
@@ -31907,8 +31901,15 @@ dwarf2out_early_finish (const char *filename)
{
unsigned i;
tree tu;
- FOR_EACH_VEC_SAFE_ELT (all_translation_units, i, tu)
- maybe_create_die_with_external_ref (tu);
+ if (external_die_map)
+ FOR_EACH_VEC_SAFE_ELT (all_translation_units, i, tu)
+ if (sym_off_pair *desc = external_die_map->get (tu))
+ {
+ dw_die_ref import = new_die (DW_TAG_imported_unit,
+ comp_unit_die (), NULL_TREE);
+ add_AT_external_die_ref (import, DW_AT_import,
+ desc->sym, desc->off);
+ }
}
early_dwarf_finished = true;