Index: include/llvm/DebugInfo/DWARF/DWARFContext.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFContext.h +++ include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -226,11 +226,7 @@ virtual bool isLittleEndian() const = 0; virtual uint8_t getAddressSize() const = 0; virtual const DWARFSection &getInfoSection() = 0; - - using TypeSectionMap = MapVector>; - - virtual const TypeSectionMap &getTypesSections() = 0; + virtual ArrayRef getTypesSections() = 0; virtual StringRef getAbbrevSection() = 0; virtual const DWARFSection &getLocSection() = 0; virtual StringRef getARangeSection() = 0; @@ -252,7 +248,7 @@ // Sections for DWARF5 split dwarf proposal. virtual const DWARFSection &getInfoDWOSection() = 0; - virtual const TypeSectionMap &getTypesDWOSections() = 0; + virtual ArrayRef getTypesDWOSections() = 0; virtual StringRef getAbbrevDWOSection() = 0; virtual const DWARFSection &getLineDWOSection() = 0; virtual const DWARFSection &getLocDWOSection() = 0; @@ -294,11 +290,15 @@ class DWARFContextInMemory : public DWARFContext { virtual void anchor(); + using TypeSectionMap = MapVector>; + StringRef FileName; bool IsLittleEndian; uint8_t AddressSize; DWARFSection InfoSection; TypeSectionMap TypesSections; + std::vector TypesSectionsPtrs; StringRef AbbrevSection; DWARFSection LocSection; StringRef ARangeSection; @@ -321,6 +321,7 @@ // Sections for DWARF5 split dwarf proposal. DWARFSection InfoDWOSection; TypeSectionMap TypesDWOSections; + std::vector TypesDWOSectionsPtrs; StringRef AbbrevDWOSection; DWARFSection LineDWOSection; DWARFSection LocDWOSection; @@ -363,7 +364,9 @@ bool isLittleEndian() const override { return IsLittleEndian; } uint8_t getAddressSize() const override { return AddressSize; } const DWARFSection &getInfoSection() override { return InfoSection; } - const TypeSectionMap &getTypesSections() override { return TypesSections; } + ArrayRef getTypesSections() override { + return TypesSectionsPtrs; + } StringRef getAbbrevSection() override { return AbbrevSection; } const DWARFSection &getLocSection() override { return LocSection; } StringRef getARangeSection() override { return ARangeSection; } @@ -390,8 +393,8 @@ // Sections for DWARF5 split dwarf proposal. const DWARFSection &getInfoDWOSection() override { return InfoDWOSection; } - const TypeSectionMap &getTypesDWOSections() override { - return TypesDWOSections; + ArrayRef getTypesDWOSections() override { + return TypesDWOSectionsPtrs; } StringRef getAbbrevDWOSection() override { return AbbrevDWOSection; } Index: lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFContext.cpp +++ lib/DebugInfo/DWARF/DWARFContext.cpp @@ -591,9 +591,9 @@ void DWARFContext::parseTypeUnits() { if (!TUs.empty()) return; - for (const auto &I : getTypesSections()) { + for (const DWARFSection *S : getTypesSections()) { TUs.emplace_back(); - TUs.back().parse(*this, I.second); + TUs.back().parse(*this, *S); } } @@ -604,9 +604,9 @@ void DWARFContext::parseDWOTypeUnits() { if (!DWOTUs.empty()) return; - for (const auto &I : getTypesDWOSections()) { + for (const DWARFSection *S : getTypesDWOSections()) { DWOTUs.emplace_back(); - DWOTUs.back().parseDWO(*this, I.second); + DWOTUs.back().parseDWO(*this, *S); } } @@ -1055,6 +1055,10 @@ Map->insert({Reloc.getOffset(), Rel}); } } + for (auto &P : TypesSections) + TypesSectionsPtrs.push_back(&P.second); + for (auto &P : TypesDWOSections) + TypesDWOSectionsPtrs.push_back(&P.second); } DWARFContextInMemory::DWARFContextInMemory(