Add support for DW_FORM_implicit_const (http://www.dwarfstd.org/ShowIssue.php?issue=141215.4) DWARFv5 feature. When this form is used attribute value goes to .debug_abbrev section (as SLEB). The functionality is checked with patched binutils-gdb, patch by Jan Kratochvil which will be published upstream this week. As this form would break any debug tool which doesn't support DWARFv5 it is guarded by dwarf version check. Attempt to use this form with dwarf version <= 4 is considered a fatal error.
Details
Diff Detail
Event Timeline
include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h | ||
---|---|---|
34–39 | These are mutually exclusive, right? (if there's a value, the byte size is zero) - could we coalesce them in some way? | |
lib/CodeGen/AsmPrinter/DIE.cpp | ||
85–87 | assert? | |
413–415 | Move this up to the form present case at the top? case dwarf::DW_FORM_implicit_const: case dwarf::DW_FORM_flag_present: ... | |
467–470 | This seems strange/incorrect - why does implicit_const have a size? Shouldn't it be zero like flag_present (& could roll this case into the flag-present case as above) | |
lib/DebugInfo/DWARF/DWARFFormValue.cpp | ||
156 | typo 'any' where 'and' is intended, perhaps? |
include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h | ||
---|---|---|
34–39 | We could use simply int64_t and bool field, smth like: int64_t ByteSizeOrValue; bool IsImplicitConst; But will it gain us much? |
- DWARFAbbreviationDeclaration::AttributeSpec struct now uses 1 64bit field for both ByteSize and implicit const attribute value (depends on Form == DW_FORM_implicit_const).
- Fixed few mistypes and reordered switch statements to be more logical.
- Classify DW_FORM_implicit_const as DWARFFormValue::FC_Constant
- Get rid of unnecessary assert()
A few things to cleanup, but feel free to commit after that. If there are any wrinkles with my suggestions do let me know.
include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h | ||
---|---|---|
34–39 | Perhaps doesn't matter - was just wondering about the size of ATtributeSpec, but it's probably not too important and we can easily optimize it later if it turns out to be important. | |
lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp | ||
61–62 | I'd probably roll this condition into the variable: bool IsImplicitConst = F == DW_FORM_implicit_const; if (IsImplicitConst) V = Data.getSLEB128(OffsetPtr); else if (auto Size = DWARFFormValue::getFixedByteSize(F)) V = *Size; Attributes.push_back(AttributeSpec(A, F, V)); if (IsImplicitConst) continue; But also - why does IsImplicitConst produce the need for this branch here, when flag_present did not? I suspect it's probably better to leave the fixed byte size calculation in and let that handle the implicit const rather than adding a special case. Ah, I see - you're passing the size-or-implicit-const into the AttributeSpec ctor. It might be more legible if it used a named ctor or the like to differentiate the parameter. How about something like this: auto FixedFormByteSize = DWARFFormValue::getFixedByteSize(F); AttributeSpecs.push_back(F == DW_FORM_implicit_const ? AttributeSpec::makeImplicitConst(A, Data.getSLEB128(OffsetPtr)) : AttributeSpec(A, F, FixedFormByteSize)); // If this abbreviation still has a fixed byte size, ... | |
135 | An implicit const should always have a value, right? Perhaps this should assert(Spec.ByteSizeOrValue) (or access the value unconditionally without an assert - the Optional will assert if there's no value) | |
136 | Using the dereference operator can be a bit less verbose than using 'getValue()': ... << *Spec.ByteSizeOrValue; | |
169 | As above, I think it should be the right thing to assert(Spec.ByteSizeOrValue) or assume it's non-empty without an assertion, even. | |
170 | As above, probably use Optional's operator* |
These are mutually exclusive, right? (if there's a value, the byte size is zero) - could we coalesce them in some way?