This is an archive of the discontinued LLVM Phabricator instance.

DebugInfo: support for DW_FORM_implicit_const
ClosedPublic

Authored by vleschuk on Jan 7 2017, 11:43 PM.

Details

Summary

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.

Diff Detail

Event Timeline

vleschuk updated this revision to Diff 83549.Jan 7 2017, 11:43 PM
vleschuk retitled this revision from to DebugInfo: support for DW_FORM_implicit_const.
vleschuk updated this object.
vleschuk added a subscriber: llvm-commits.
vleschuk updated this revision to Diff 83572.Jan 8 2017, 1:59 PM

Fix mistype in unittest.

dblaikie added inline comments.Jan 9 2017, 10:23 AM
include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
34–38

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?

vleschuk added inline comments.Jan 9 2017, 11:30 AM
include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
34–38

We could use simply int64_t and bool field, smth like:

int64_t ByteSizeOrValue;
bool IsImplicitConst;

But will it gain us much?

vleschuk updated this revision to Diff 83780.Jan 9 2017, 10:54 PM
  • 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.
vleschuk marked 6 inline comments as done.Jan 9 2017, 10:55 PM
vleschuk updated this revision to Diff 83789.Jan 10 2017, 3:02 AM
  • Classify DW_FORM_implicit_const as DWARFFormValue::FC_Constant
  • Get rid of unnecessary assert()
dblaikie accepted this revision.Jan 10 2017, 7:35 AM
dblaikie edited edge metadata.

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–38

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*

This revision is now accepted and ready to land.Jan 10 2017, 7:35 AM
This revision was automatically updated to reflect the committed changes.
vleschuk marked 4 inline comments as done.