Page MenuHomePhabricator

Modify DWARFFormValue to remember the DWARFUnit that it was decoded with.
ClosedPublic

Authored by clayborg on Oct 27 2016, 5:17 PM.

Details

Summary

Modifying DWARFFormValue to remember the DWARFUnit that it was encoded with can simplify the usage of instances of this class. Previously users would have to try and pass in the same DWARFUnit that was used to decode the form value and there was a possibility that a different DWARFUnit might be supplied to the functions that extract values (strings, CU relative references, addresses) and cause problems. This fixes this potential issue by storing the DWARFUnit inside the DWARFFormValue so that this mistake can't be made. Instances of DWARFFormValue are not stored permanently and are used as temporary values, so the increase in size of an instance of DWARFFormValue isn't a big deal. This makes decoding form values more bullet proof and is a change that will be used by future modifications.

Diff Detail

Event Timeline

clayborg updated this revision to Diff 76137.Oct 27 2016, 5:17 PM
clayborg retitled this revision from to Modify DWARFFormValue to remember the DWARFUnit that it was decoded with..
clayborg updated this object.
clayborg set the repository for this revision to rL LLVM.
aprantl edited edge metadata.Oct 28 2016, 4:12 PM

Can you say anything about the impact this change has on the memory footprint? Do we typically keep many DWARFFormValues around?

include/llvm/DebugInfo/DWARF/DWARFFormValue.h
52

You can doxygen'ify this by using

dwarf::Form Form; ///< Form for this value.

or

/// Form for this value.
dwarf::Form Form;
lib/DebugInfo/DWARF/DWARFFormValue.cpp
136

A DataExtractor is only a StringRef + 2x uint8_t. Are we saving anything by passing it by reference?

All DWARFFormValue objects are temporaries. I mentioned in the original description that this won't affect memory because of this.

include/llvm/DebugInfo/DWARF/DWARFFormValue.h
52

This is how it was, I didn't change it, but I can add the doxygen /// if desired.

lib/DebugInfo/DWARF/DWARFFormValue.cpp
136

It just avoids the copy. It passes one pointer for the reference versus 2 pointers + 2 uint8_t values.

This is probably fine then. Fred, this touches a bunch of dsymutil code — any concerns?

friss edited edge metadata.Oct 28 2016, 5:24 PM

Looks globally good. Some nits:

include/llvm/DebugInfo/DWARF/DWARFUnit.h
198–201

llvm-dsymutil has a helper that does the same computation. Please add this helper and remove dsymutil's one in a preliminary commit.

tools/dsymutil/DwarfLinker.cpp
1487–1490

If the FormValue holds the Unit, let's stop passing it around in small helpers like this. RefValue->getUnit() can be used below.

2358

U is just unused here AFAICS, just remove it.

aprantl accepted this revision.Oct 29 2016, 11:05 AM
aprantl edited edge metadata.

LGTM (with feedback addressed).
Thanks!

This revision is now accepted and ready to land.Oct 29 2016, 11:05 AM

I will fix the one issue Fred Riss asked for and commit.

include/llvm/DebugInfo/DWARF/DWARFUnit.h
201

I will fix this.

tools/dsymutil/DwarfLinker.cpp
1490

I will fix this in a commit that is coming up soon. I am going to make a DWARFDIE class that encapsulates both the DwarfUnit and the DWARFDebugInfoEntryMinimal into one unit so all raw DWARFUnit objects will no longer be passed around. So I am going to defer fixing this until that patch since the new patch will take care of this.

clayborg closed this revision.Oct 31 2016, 9:55 AM

Committed with SVN revision 285594.