On Wed, Nov 14, 2018 at 12:58 PM Nathan Sidwell <nat...@acm.org> wrote: > > PR88006 and 87462 turn out to be the same problem, but started by > different commits. > > The problem is that debug wants to emit a constant (for a non-type > template parameter of a template instantiation) that refers to the > address of some local function. That local might not be emitted though. > > gen_remaining_tmpl_value_param_die_attribute is aware of the problem: > /* We do this in two phases - first get the cases we can > handle during early-finish, preserving those we cannot > (containing symbolic constants where we don't yet know > whether we are going to output the referenced symbols). > For those we try again at late-finish. */ > > But the second phase unconditionally emits the constant: > if (! early_dwarf > && (dwarf_version >= 5 || !dwarf_strict)) > loc = loc_descriptor_from_tree (e->arg, 2, NULL); > > and loc_descriptor_from_tree eventually ends up in > const_ok_for_output_1. That function assumes pretty much any non > SYMBOL_REF_EXTERNAL_P SYMBOL_REF is accessible. That's not true. > > I'm not sure if there's a more canonical way of checking for a > local-decl's emission, but not having a symtab entry seems significant? > > booted & tested on x86_64-linux, ok?
Hmm, there is reference_to_unused () used in a related case. But generally for late emission such references are "OK" and expected to be pruned later by resolve_addr () (which I see we do not call for type units?!). Quote: /* Resolve DW_OP_addr and DW_AT_const_value CONST_STRING arguments to an address in .rodata section if the string literal is emitted there, or remove the containing location list or replace DW_AT_const_value with DW_AT_location and empty location expression, if it isn't found in .rodata. Similarly for SYMBOL_REFs, keep only those that refer to something that has been emitted in the current CU. */ static void resolve_addr (dw_die_ref die) { Richard. > > nathan > > -- > Nathan Sidwell