https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94450

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at gcc dot gnu.org

--- Comment #13 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to rguent...@suse.de from comment #11)

> Note that as I read the DWARF spec changing the
> early CUs to DW_TAG_partial_unit and then again importing those
> (the spec suggests you need to import DW_TAG_partial_units) would
> not reflect documented semantics either.

It's not my understanding from the spec that DW_TAG_partial_units are required
to be imported. AFAIU, it's just that in all the use-cases there using
DW_TAG_partial_unit, an import happens to be required.

OK, so lets look at the use cases described in the spec at E.1.

I. classic dwz: factor out into partial unit, add imports:
...
    DW_TAG_compile_unit
      DW_AT_name cu1
L1:   DIEx
      DIEy
        DW_AT_type L1
    DW_TAG_compile_unit
      DW_AT_name cu2
L2:   DIEx
      DIEz
        DW_AT_type L2

->

L3: DW_TAG_partial_unit
L4:   DIEx
    DW_TAG_compile_unit
      DW_TAG_imported_unit
        DW_AT_import L3
      DW_AT_name cu1
      DIEy
        DW_AT_type L4
    DW_TAG_compile_unit
      DW_TAG_imported_unit
        DW_AT_import L3
      DW_AT_name cu2
      DIEz
        DW_AT_type L4
...

II. dwz --devel-uni-lang --devel-gen-cu: factor out into DW_TAG_compile_unit,
no imports, exploit global namespace:
...
    DW_TAG_compile_unit
      DW_AT_name cu1
L1:   DIEx
      DIEy
        DW_AT_type L1
    DW_TAG_compile_unit
      DW_AT_name cu2
L2:   DIEx
      DIEz
        DW_AT_type L2

->

    DW_TAG_compile_unit
L4:   DIEx
    DW_TAG_compile_unit
      DW_AT_name cu1
      DIEy
        DW_AT_type L4
    DW_TAG_compile_unit
      DW_AT_name cu2
      DIEz
        DW_AT_type L4
...

III. #include in namespace:
...
    DW_TAG_compile_unit
      DW_AT_name cu1
      DW_TAG_namespace bla1
L1:     DIEx
        DIEy
          DW_AT_type L1
    DW_TAG_compile_unit
      DW_AT_name cu2
      DW_TAG_namespace bla2
L2:     DIEx
        DIEz
          DW_AT_type L2

->

L3: DW_TAG_partial_unit
L4:   DIEx
    DW_TAG_compile_unit
      DW_AT_name cu1
      DW_TAG_namespace bla1
        DW_TAG_imported_unit
          DW_AT_import L3
        DIEy
          DW_AT_type L4
    DW_TAG_compile_unit
      DW_AT_name cu2
      DW_TAG_namespace bla2
        DW_TAG_imported_unit
          DW_AT_import L3
        DIEz
          DW_AT_type L4
...

So indeed, in all cases where DW_TAG_partial_unit is used, we use an import,
but that's because it's applicable to the transformation, and we're just doing
an entirely different transformation here:
...
    DW_TAG_compile_unit
      DW_AT_name cu1
      DW_TAG_variable
        DW_AT_name var1
        DW_AT_location

->

    DW_TAG_partial_unit
L1:   DW_TAG_variable
        DW_AT_name var1
    DW_TAG_compile_unit
      DW_AT_name cu1
      DW_TAG_variable
        DW_AT_abstract_origin L1
        DW_AT_location
...
We fabricate a new abstract DW_TAG_variable DIE out of thin air, then try to
hide that fact by placing it in a DW_TAG_partial_unit, much like is done at
III. Only in contrast to III, we don't want to reintroduce it in another
context, we want it to keep hidden, so there's no import.

Reply via email to