diff options
author | David Blaikie <dblaikie@gmail.com> | 2019-05-10 19:15:29 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2019-05-10 19:15:29 +0000 |
commit | 7598b71488d8775f913873e95a95b7539601d71a (patch) | |
tree | d6371b956e2713babac58112c313b41236e7642e /llvm/lib | |
parent | f62c266de76e4dcae234f3b0ae77ac425ceeddc1 (diff) | |
download | bcm5719-llvm-7598b71488d8775f913873e95a95b7539601d71a.tar.gz bcm5719-llvm-7598b71488d8775f913873e95a95b7539601d71a.zip |
DebugInfo: Only move types out of type units if they're named or type united
Follow up to r359122, after a bug was reported in it - the original
change too aggressively tried to move related types out of type units,
which included unnamed types (like array types) which can't reasonably
be declared-but-not-defined.
A step beyond that is that some types in type units can be anonymous, if
they are types with a name for linkage purposes (eg: "typedef struct { }
x;"). So ensure those don't get turned into plain declarations (without
signatures) because, lacking names, they can't be resolved to the
definition.
[Also include a fix for llvm-dwarfdump/libDebugInfoDWARF to pretty print
types in type units]
llvm-svn: 360458
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp | 10 |
3 files changed, 15 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 3aa404ed4e9..d9e680846b3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -639,7 +639,8 @@ DIE *DwarfUnit::createTypeDIE(const DIScope *Context, DIE &ContextDIE, else if (auto *STy = dyn_cast<DISubroutineType>(Ty)) constructTypeDIE(TyDIE, STy); else if (auto *CTy = dyn_cast<DICompositeType>(Ty)) { - if (DD->generateTypeUnits() && !Ty->isForwardDecl()) { + if (DD->generateTypeUnits() && !Ty->isForwardDecl() && + (Ty->getRawName() || CTy->getRawIdentifier())) { // Skip updating the accelerator tables since this is not the full type. if (MDString *TypeId = CTy->getRawIdentifier()) DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp index 3015ce2e94b..7d80f2eb75b 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -429,9 +429,11 @@ DWARFDie::getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const { DWARFDie DWARFDie::getAttributeValueAsReferencedDie(const DWARFFormValue &V) const { - if (auto SpecRef = toReference(V)) { - if (auto SpecUnit = U->getUnitVector().getUnitForOffset(*SpecRef)) - return SpecUnit->getDIEForOffset(*SpecRef); + if (auto SpecRef = V.getAsRelativeReference()) { + if (SpecRef->Unit) + return SpecRef->Unit->getDIEForOffset(SpecRef->Unit->getOffset() + SpecRef->Offset); + if (auto SpecUnit = U->getUnitVector().getUnitForOffset(SpecRef->Offset)) + return SpecUnit->getDIEForOffset(SpecRef->Offset); } return DWARFDie(); } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp index bdc2e54b3e9..8f2524246a8 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp @@ -639,6 +639,12 @@ DWARFFormValue::getAsSectionedAddress() const { } Optional<uint64_t> DWARFFormValue::getAsReference() const { + if (auto R = getAsRelativeReference()) + return R->Unit ? R->Unit->getOffset() + R->Offset : R->Offset; + return None; +} + +Optional<DWARFFormValue::UnitOffset> DWARFFormValue::getAsRelativeReference() const { if (!isFormClass(FC_Reference)) return None; switch (Form) { @@ -649,11 +655,11 @@ Optional<uint64_t> DWARFFormValue::getAsReference() const { case DW_FORM_ref_udata: if (!U) return None; - return Value.uval + U->getOffset(); + return UnitOffset{const_cast<DWARFUnit*>(U), Value.uval}; case DW_FORM_ref_addr: case DW_FORM_ref_sig8: case DW_FORM_GNU_ref_alt: - return Value.uval; + return UnitOffset{nullptr, Value.uval}; default: return None; } |