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.
Details
Diff Detail
Event Timeline
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?
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. |
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. |
You can doxygen'ify this by using
dwarf::Form Form; ///< Form for this value.
or