public inbox for
 help / color / mirror / Atom feed
* [Bug default/25449] New: Factor out compilation units
@ 2020-01-01  0:00 vries at gcc dot
  2020-01-01  0:00 ` [Bug default/25449] " vries at gcc dot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vries at gcc dot @ 2020-01-01  0:00 UTC (permalink / raw)
  To: dwz

            Bug ID: 25449
           Summary: Factor out compilation units
           Product: dwz
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: default
          Assignee: nobody at sourceware dot org
          Reporter: vries at gcc dot
                CC: dwz at sourceware dot org
  Target Milestone: ---

The dwarf standard contains "Appendix E -- DWARF Compression and Duplicate
Elimination (informative)", describing a technique on how to generate smaller
debug information:
to break up the debug information of a compilation into separate normal and
partial compilation units, each consisting of one or more sections. By
arranging that a sufficiently similar partitioning occurs in other
compilations, a suitable system linker can delete redundant groups of sections
when combining object files.

DWZ implements this scheme, but with the approach (described in pre-link terms
in the appendix) applied post-link.

It does this by:
- moving common DIEs into partial units (tagged with DW_TAG_partial_unit),
- generating DW_TAG_imported_unit/DW_AT_import to import the partial units
  into the compilation units which originally contained the DIEs
- referencing DIEs in partial units using DW_FORM_ref_addr, when referenced
  the originally containing compilation units or other partial units.

The appendix has a bit though on "Use of DW_TAG_compile_unit versus
A section group compilation unit that uses DW_TAG_compile_unit is like any
other compilation unit, in that its contents are evaluated by consumers as
though it were an ordinary compilation unit.

An #include directive appearing outside any other declarations is a good
candidate to be represented using DW_TAG_compile_unit.

However, an #include appearing inside a C++ namespace declaration or a
function, for example, is not a good candidate because the entities included
are not necessarily file level entities.


Consequently a compiler must use DW_TAG_partial_unit (instead of
DW_TAG_compile_unit) in a section group whenever the section group contents are
not necessarily globally visible.

This directs consumers to ignore that compilation unit when scanning top level
declarations and definitions.

The DW_TAG_partial_unit compilation unit will be referenced from elsewhere and
the referencing locations give the appropriate context for interpreting the
partial compilation unit.

So, there also is an option to tag the created units with DW_TAG_compile_unit
instead of DW_TAG_partial_unit, which means no requirement to create
DW_TAG_imported_unit/DW_AT_import for such units, which means better

The first C++ example in the appendix shows this situation, and states:
This example uses DW_TAG_compile_unit for the section group, implying that the
contents of the compilation unit are globally visible (in accordance with C++
language rules). DW_TAG_partial_unit is not needed for the same reason.

So, as a first step we could do a optimization in DWZ to look at all the items
that are selected to be moved into a PU, and decide whether we can transform
the PU into a CU and drop the imports.

You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-23 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01  0:00 [Bug default/25449] New: Factor out compilation units vries at gcc dot
2020-01-01  0:00 ` [Bug default/25449] " vries at gcc dot
2020-01-01  0:00 ` vries at gcc dot
2020-01-01  0:00 ` vries at gcc dot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).