On Tue, Jun 26, 2018 at 8:43 AM, Richard Biener <rguent...@suse.de> wrote:
>
> A patch from Honza not LTO streaming DECL_ORIGINAL_TYPE ends up
> ICEing during LTO bootstrap because we end up not re-using the
> DIE we create late during LTRANS for a subprogram because its
> parent is a namespace rather than a CU DIE (or a module).
>
> I'm wondering of the general reason why we enforce (inconsistently)
> "We always want the DIE for this function that has the *_pc attributes to
> be under comp_unit_die so the debugger can find it."
> We indeed generate a specification DIE rooted at the CU in addition to the
> declaration DIE inside the namespace for sth as simple as
>
> namespace Foo { void foo () {} }

The reason was to make it easier for debuggers to collect function
definitions by scanning the top-level DIEs.  I don't know how
useful/important that is to actual debuggers nowadays, since there are
various accelerated lookup tables as well.

> anyhow - the comment also says "We also need to do this [re-use the DIE]
> for abstract instances of inlines, since the spec requires the out-of-line
> copy to have the same parent.".  Not sure what condition this part of
> the comment applies to.

I think it's saying that we shouldn't re-use an in-class declaration
die for the abstract instance of an inline, just like we shouldn't
re-use it for a non-inline definition.

Incidentally, the same parent was only required by DWARF 2; DWARF 3+
say it's typical but not required.

> So my fix is to move the || get_AT (old_die, DW_AT_abstract_origin)
> check I added for early LTO debug to a global override - forcing
> DIE re-use for any DIE with an abstract origin set.  That is, all
> concrete instances are fine where they are.  That also avoids
> double-indirection DW_AT_specification -> DW_AT_abstract_origin -> DIE.
>
> But as said, I wonder about the overall condition, esp. the
> DW_TAG_module special-casing (but not at the same time
> special-casing DW_TAG_namespace or DW_TAG_partial_unit).

Hmm, the DW_TAG_module check seems to have come in with the
early-debug merge.  I don't know what the rationale was for that; it
certainly does weaken the case for treating CU scope specially.

As for DW_TAG_partial_unit, probably the is_cu_die check should change
to is_unit_die.

> LTO bootstrap is in progress on x86_64-unknown-linux-gnu.
>
> OK if that succeeds?

OK.

Jason

Reply via email to