This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

This is Patch 4 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:17 AM
aprantl added inline comments.Jul 30 2018, 7:54 AM
llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
107 ↗(On Diff #157072)

Why is Units capitalized? It's neither a type name and or a concept in DWARF (a compile/type unit is).

126 ↗(On Diff #157072)

Doxygen comment that explains that this returns all kinds of units?

probinson added inline comments.Jul 30 2018, 10:59 AM
llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
107 ↗(On Diff #157072)

Because the old comment had it capitalized. I will fix it.

126 ↗(On Diff #157072)

This entire class hierarchy could use doxygen-izing.

JDevlieghere added inline comments.Jul 31 2018, 3:37 AM
llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
126 ↗(On Diff #157072)

I guess it's slightly more pressing here, as otherwise you'd be left to guess whether it includes the DWO kind?

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
555 ↗(On Diff #157072)

I recently learned about this "trick" where you define an enum like enum { parseLazy = true };. Not sure if it's worth it here but I (personally) think it's nicer than the comment.

probinson added inline comments.Jul 31 2018, 6:31 AM
llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
126 ↗(On Diff #157072)

Will doxygen-ize all these new methods to clarify.

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
555 ↗(On Diff #157072)

I can do something along those lines.

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

Rebase. Add to and improve commentary.

probinson marked 3 inline comments as done.Jul 31 2018, 9:33 AM
probinson added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
555 ↗(On Diff #157072)

Oops forgot this one. Will try again before committing.

aprantl accepted this revision.Jul 31 2018, 9:58 AM
aprantl added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
101 ↗(On Diff #158304)

Side note:I find this loop to be a bit hard to follow... but it's been this way since before you touched it.

107 ↗(On Diff #158304)

might be nice to comment what the break means (did the parsing fail, are we at the end?).

This revision is now accepted and ready to land.Jul 31 2018, 9:58 AM
probinson added inline comments.Jul 31 2018, 10:43 AM
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
101 ↗(On Diff #158304)

And it took me the longest time to work out what it was doing; I hope the comment helps. Coming up with a better name for I might aid readability too. Another one for The List.

107 ↗(On Diff #158304)

Right, it means parsing failed. The isValidOffset at the top decides when we've reached the end of the section. I'll add another comment here.

This revision was automatically updated to reflect the committed changes.