[llvm] [llvm/DWARF] Recursively resolve DW_AT_signature references (PR #97423)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 10:11:16 PDT 2024


================
@@ -312,27 +307,19 @@ DWARFDie::getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const {
 
 DWARFDie
 DWARFDie::getAttributeValueAsReferencedDie(const DWARFFormValue &V) const {
-  DWARFDie Result;
   if (auto SpecRef = V.getAsRelativeReference()) {
----------------
dwblaikie wrote:

Seems a bit questionable that `getAsRelativeReference` returns a valid value for `DW_FORM_ref_sig8` - it's not a CU-relative reference form... (eg: if one had called `getAttributeValueAsReferencedDie` on a ref_sig8 before this patch, it would have walked off to some garbage offset, right? Interpreting the sig8 as an offset)

So might be worth changing it to not do that and having an explicit/separate case here?

(aside: this case is probably untested? How'd you come across changing this function? Clang/LLVM doesn't produce direct references via ref_sig8, only via the skeleton type DIEs... ah, I see, the `findRecursively` change would cause us to call `getAttributeValueAsReferencedDie(DW_AT_signature)`? OK.

Incidentally this has probably added support for some DWARF that GCC produces - where it references the type unit directly from DW_AT_type, maybe? Currently llvm-dwarfdump doesn't resolve such references ( https://godbolt.org/z/E5boxcj1r - note the `DW_TAG_variable`'s ` DW_AT_type	(0xc949e2ea8b91cfb0)` only has the signature, and I guess with this patch maybe we now get ` DW_AT_type	(0xc949e2ea8b91cfb0 "t1")`?)

https://github.com/llvm/llvm-project/pull/97423


More information about the llvm-commits mailing list