diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2022-01-27 22:06:42 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2022-01-27 22:06:42 +0000 |
commit | 6f8fc217eaa12bf657be1c6468ed9938d10168b3 (patch) | |
tree | a1fd89b864d9b93e2ad68fe1dcf7afee2e3c8d76 /llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | |
parent | 77fc4c146f0870ffb09c1afb823ccbe742c5e6ff (diff) | |
download | src-6f8fc217eaa12bf657be1c6468ed9938d10168b3.tar.gz src-6f8fc217eaa12bf657be1c6468ed9938d10168b3.zip |
Vendor import of llvm-project main llvmorg-14-init-17616-g024a1fab5c35.vendor/llvm-project/llvmorg-14-init-17616-g024a1fab5c35
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 95135c95e8d2..ef50ad53650a 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -695,14 +695,30 @@ void DWARFContext::dump( DWARFTypeUnit *DWARFContext::getTypeUnitForHash(uint16_t Version, uint64_t Hash, bool IsDWO) { - // FIXME: Check for/use the tu_index here, if there is one. - for (const auto &U : IsDWO ? dwo_units() : normal_units()) { - if (DWARFTypeUnit *TU = dyn_cast<DWARFTypeUnit>(U.get())) { - if (TU->getTypeHash() == Hash) - return TU; + parseDWOUnits(LazyParse); + + if (const auto &TUI = getTUIndex()) { + if (const auto *R = TUI.getFromHash(Hash)) + return dyn_cast_or_null<DWARFTypeUnit>( + DWOUnits.getUnitForIndexEntry(*R)); + return nullptr; + } + + struct UnitContainers { + const DWARFUnitVector &Units; + Optional<DenseMap<uint64_t, DWARFTypeUnit *>> ⤅ + }; + UnitContainers Units = IsDWO ? UnitContainers{DWOUnits, DWOTypeUnits} + : UnitContainers{NormalUnits, NormalTypeUnits}; + if (!Units.Map) { + Units.Map.emplace(); + for (const auto &U : IsDWO ? dwo_units() : normal_units()) { + if (DWARFTypeUnit *TU = dyn_cast<DWARFTypeUnit>(U.get())) + (*Units.Map)[TU->getTypeHash()] = TU; } } - return nullptr; + + return (*Units.Map)[Hash]; } DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) { @@ -1098,6 +1114,7 @@ static Optional<uint64_t> getTypeSize(DWARFDie Type, uint64_t PointerSize) { return PointerSize; } case DW_TAG_const_type: + case DW_TAG_immutable_type: case DW_TAG_volatile_type: case DW_TAG_restrict_type: case DW_TAG_typedef: { |