This is an archive of the discontinued LLVM Phabricator instance.

[clang][DebugInfo] Attach DW_AT_default_value to template arg metadata regardless of DwarfVersion
AcceptedPublic

Authored by Michael137 on Dec 13 2022, 2:50 AM.

Details

Reviewers
aprantl
dblaikie
Summary

Summary

Starting with DWARFv5, DW_AT_default_value can be used to indicate
that a template argument has a default value. With this patch Clang
will attach the attribute to the debug metadata regardless of version.

In a follow-up patch we will change llvm to emit this attribute in
earlier versions of DWARF, unless compiling with -gstrict-dwarf.

Details

  • Previously the DwarfVersion check in CGDebugInfo was inconsistent:

For non-type template arguments we attached the attribute to the debug
metadata in DWARFv5 only. Whereas for type template arguments we didn't
have such a version restriction. With this patch we attach the attribute
regardless of DWARF version (and instead offload the check to the AsmPrinter
in a future patch).

Diff Detail

Event Timeline

Michael137 created this revision.Dec 13 2022, 2:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2022, 2:50 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Michael137 requested review of this revision.Dec 13 2022, 2:50 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 13 2022, 2:50 AM
  • Fix test formatting
Michael137 edited the summary of this revision. (Show Details)Dec 13 2022, 6:40 AM

(This should be committed in two parts - the LLVM part first, then the Clang part - since they can be separated, they should be - but happy to review it altogether)

llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
1856 ↗(On Diff #482419)

Maybe this could be a more general function? It could take a version and then have a general name "isCompatibleWithVersion(X)" and be used for other strict DWARF+version checks?

1857–1858 ↗(On Diff #482419)

You can drop these - there's tons of non-null assumptions throughout the codebase, most aren't asserted.

  • Split clang and llvm changes

(This should be committed in two parts - the LLVM part first, then the Clang part - since they can be separated, they should be - but happy to review it altogether)

Split the review: https://reviews.llvm.org/D139953

Updated the version check to be a bit more general.

Michael137 retitled this revision from [clang][DebugInfo] Backport emitting DW_AT_default_value for default template arguments to [clang][DebugInfo] Attach DW_AT_default_value to template arg metadata regardless of DwarfVersion.Dec 13 2022, 9:58 AM
Michael137 edited the summary of this revision. (Show Details)
dblaikie accepted this revision.Dec 13 2022, 12:27 PM

Looks good, thanks!

This revision is now accepted and ready to land.Dec 13 2022, 12:27 PM