diff options
author | Richard Biener <rguenther@suse.de> | 2015-06-02 12:33:02 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2015-06-02 12:33:02 +0000 |
commit | 71fa02e0d8932de4ba1a527f50df98bf211f2ffd (patch) | |
tree | 22931bbee0d1b3cac750714c57949b3adf241f39 /gcc/dwarf2out.c | |
parent | 1817fe58f258d6de8b7716927bad077d811fe39a (diff) | |
download | gcc-71fa02e0d8932de4ba1a527f50df98bf211f2ffd.zip gcc-71fa02e0d8932de4ba1a527f50df98bf211f2ffd.tar.gz gcc-71fa02e0d8932de4ba1a527f50df98bf211f2ffd.tar.bz2 |
re PR debug/65549 (crash in htab_hash_string with -flto -g)
2015-06-02 Richard Biener <rguenther@suse.de>
PR debug/65549
* dwarf2out.c (lookup_context_die): New function.
(resolve_addr): Avoid forcing a full DIE for the
target of a DW_TAG_GNU_call_site during late compilation.
Instead create a stub DIE without a type if we have a
context DIE present.
* g++.dg/lto/pr65549_0.C: New testcase.
From-SVN: r224029
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 15c545e..1116f86 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -20621,6 +20621,28 @@ is_naming_typedef_decl (const_tree decl) != TYPE_NAME (TREE_TYPE (decl)))); } +/* Looks up the DIE for a context. */ + +static inline dw_die_ref +lookup_context_die (tree context) +{ + if (context) + { + /* Find die that represents this context. */ + if (TYPE_P (context)) + { + context = TYPE_MAIN_VARIANT (context); + dw_die_ref ctx = lookup_type_die (context); + if (!ctx) + return NULL; + return strip_naming_typedef (context, ctx); + } + else + return lookup_decl_die (context); + } + return comp_unit_die (); +} + /* Returns the DIE for a context. */ static inline dw_die_ref @@ -23949,12 +23971,22 @@ resolve_addr (dw_die_ref die) { tree tdecl = SYMBOL_REF_DECL (a->dw_attr_val.v.val_addr); dw_die_ref tdie = lookup_decl_die (tdecl); + dw_die_ref cdie; if (tdie == NULL && DECL_EXTERNAL (tdecl) - && DECL_ABSTRACT_ORIGIN (tdecl) == NULL_TREE) + && DECL_ABSTRACT_ORIGIN (tdecl) == NULL_TREE + && (cdie = lookup_context_die (DECL_CONTEXT (tdecl)))) { - force_decl_die (tdecl); - tdie = lookup_decl_die (tdecl); + /* Creating a full DIE for tdecl is overly expensive and + at this point even wrong when in the LTO phase + as it can end up generating new type DIEs we didn't + output and thus optimize_external_refs will crash. */ + tdie = new_die (DW_TAG_subprogram, cdie, NULL_TREE); + add_AT_flag (tdie, DW_AT_external, 1); + add_AT_flag (tdie, DW_AT_declaration, 1); + add_linkage_attr (tdie, tdecl); + add_name_and_src_coords_attributes (tdie, tdecl); + equate_decl_number_to_die (tdecl, tdie); } if (tdie) { |