Message ID | alpine.LSU.2.11.1506111105180.14687@zhemvz.fhfr.qr |
---|---|
State | New |
Headers | show |
On 06/11/2015 11:06 AM, Richard Biener wrote: > FYI, I decided to backport the fix causing this regression to the > 4.8 branch today, guarded with in_lto_p, thus eliminating the effect > on non-LTO links. The adjusted patch looks like the following and > I'll also adjust the 4.9 branch accordingly, leaving the GCC 5 branch > with the original fix. That sounds perfect: thank you Richard! I am about to commit the original fix on mainline: should I still open a bugreport before commiting it to the GCC 5 branch?
On Thu, 11 Jun 2015, Pierre-Marie de Rodat wrote: > On 06/11/2015 11:06 AM, Richard Biener wrote: > > FYI, I decided to backport the fix causing this regression to the > > 4.8 branch today, guarded with in_lto_p, thus eliminating the effect > > on non-LTO links. The adjusted patch looks like the following and > > I'll also adjust the 4.9 branch accordingly, leaving the GCC 5 branch > > with the original fix. > > That sounds perfect: thank you Richard! I am about to commit the original fix > on mainline: should I still open a bugreport before commiting it to the GCC 5 > branch? Yes please. Thanks, Richard.
On 06/11/2015 11:21 AM, Richard Biener wrote: >> That sounds perfect: thank you Richard! I am about to commit the original fix >> on mainline: should I still open a bugreport before commiting it to the GCC 5 >> branch? > > Yes please. For the record, as you already noticed, I opened PR debug/66503. Original fix pushed on both trunk and the GCC 5 branch. Thank you very much for your help! Should I close the PR, now?
Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 224363) +++ gcc/dwarf2out.c (working copy) @@ -19697,6 +19697,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 @@ -22751,8 +22773,25 @@ resolve_addr (dw_die_ref die) && DECL_EXTERNAL (tdecl) && DECL_ABSTRACT_ORIGIN (tdecl) == NULL_TREE) { - force_decl_die (tdecl); - tdie = lookup_decl_die (tdecl); + dw_die_ref cdie; + if (!in_lto_p) + { + force_decl_die (tdecl); + tdie = lookup_decl_die (tdecl); + } + else if ((cdie = lookup_context_die (DECL_CONTEXT (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) {