This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo/DWARF] [2/4] De-segregate type units and compile units. NFC
ClosedPublic

Authored by probinson on Jul 24 2018, 10:14 AM.

Details

Summary

This is Patch 2 of 4 NFC refactorings to handle type units and compile
units more consistently and with less concern about the object-file
section that they came from.

Patch 1 replaces the templated DWARFUnitSection with a non-templated
version. That is, instead of being a SmallVector of pointers to a
specific unit kind, it is now a SmallVector of pointers to the base
class for both type and compile units. Virtual methods are magic.

Patch 2 takes the existing std::deque<DWARFUnitSection> for type units
and makes it a simple DWARFUnitSection, simplifying the handling of
type units and making it more consistent with compile units.

Patch 3 simply renames DWARFUnitSection to DWARFUnitVector, as the
object-file section of a unit is nearly irrelevant now.

Patch 4 combines separate DWARFUnitVectors for compile and type units
into a single DWARFUnitVector that contains both. For now the
implementation distinguishes compile units from type units by putting
all compile units at the front of the vector, reflecting the DWARF v4
distinction between .debug_info and .debug_types sections. A future
patch will change this to allow the free mixing of unit kinds, as is
specified by DWARF v5.

Diff Detail

Repository
rL LLVM

Event Timeline

probinson created this revision.Jul 24 2018, 10:14 AM
aprantl accepted this revision.Jul 30 2018, 7:50 AM

SGTM.

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
838 ↗(On Diff #157070)

Where did the emplace_back go?

llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
59 ↗(On Diff #157070)

why is this no longer necessary?

This revision is now accepted and ready to land.Jul 30 2018, 7:50 AM
probinson added inline comments.Jul 30 2018, 10:57 AM
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
838 ↗(On Diff #157070)

It's gone, because DWOTUs is no longer a deque of DWARFUnitSection, it is simply a single DWARFUnitSection.

llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
59 ↗(On Diff #157070)

More than unnecessary, it gets in the way. The parse method is called once per object-file section, and a single DWARFUnitSection now contains info from multiple sections. So, we have to be able to call it multiple times.
It's the caller's responsibility to avoid re-parsing now. Hmm which ought to be documented in a comment.

dblaikie added inline comments.Jul 30 2018, 7:33 PM
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
59 ↗(On Diff #157070)

More than a comment - I reckon these functions need a different name to call them out as being different from the other DWARF parsing objects semantics (construct -> parse -> use, this one is: construct -> {parse, use}*). As discussed on the llvm-dev thread, maybe something like "addSectionContents" or the like.

probinson added inline comments.Jul 31 2018, 6:25 AM
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
59 ↗(On Diff #157070)

Right, thanks for the reminder, will do.

probinson updated this revision to Diff 158301.Jul 31 2018, 9:28 AM

Rebase. Renamed 'parse' methods to start with 'addUnits' to reflect their cumulative nature.

probinson marked an inline comment as done.Jul 31 2018, 9:29 AM
dblaikie accepted this revision.Jul 31 2018, 2:42 PM
This revision was automatically updated to reflect the committed changes.