File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed
include/llvm/DebugInfo/DWARF Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ class raw_ostream;
5252// / information parsing. The actual data is supplied through DWARFObj.
5353class DWARFContext : public DIContext {
5454 DWARFUnitVector NormalUnits;
55+ Optional<DenseMap<uint64_t , DWARFTypeUnit*>> NormalTypeUnits;
5556 std::unique_ptr<DWARFUnitIndex> CUIndex;
5657 std::unique_ptr<DWARFGdbIndex> GdbIndex;
5758 std::unique_ptr<DWARFUnitIndex> TUIndex;
@@ -70,6 +71,7 @@ class DWARFContext : public DIContext {
7071 std::unique_ptr<AppleAcceleratorTable> AppleObjC;
7172
7273 DWARFUnitVector DWOUnits;
74+ Optional<DenseMap<uint64_t , DWARFTypeUnit*>> DWOTypeUnits;
7375 std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;
7476 std::unique_ptr<DWARFDebugMacro> MacinfoDWO;
7577 std::unique_ptr<DWARFDebugMacro> MacroDWO;
Original file line number Diff line number Diff line change @@ -695,14 +695,30 @@ void DWARFContext::dump(
695695
696696DWARFTypeUnit *DWARFContext::getTypeUnitForHash (uint16_t Version, uint64_t Hash,
697697 bool IsDWO) {
698- // FIXME: Check for/use the tu_index here, if there is one.
699- for (const auto &U : IsDWO ? dwo_units () : normal_units ()) {
700- if (DWARFTypeUnit *TU = dyn_cast<DWARFTypeUnit>(U.get ())) {
701- if (TU->getTypeHash () == Hash)
702- return TU;
698+ parseDWOUnits (LazyParse);
699+
700+ if (const auto &TUI = getTUIndex ()) {
701+ if (const auto *R = TUI.getFromHash (Hash))
702+ return dyn_cast_or_null<DWARFTypeUnit>(
703+ DWOUnits.getUnitForIndexEntry (*R));
704+ return nullptr ;
705+ }
706+
707+ struct UnitContainers {
708+ const DWARFUnitVector &Units;
709+ Optional<DenseMap<uint64_t , DWARFTypeUnit *>> ⤅
710+ };
711+ UnitContainers Units = IsDWO ? UnitContainers{DWOUnits, DWOTypeUnits}
712+ : UnitContainers{NormalUnits, NormalTypeUnits};
713+ if (!Units.Map ) {
714+ Units.Map .emplace ();
715+ for (const auto &U : IsDWO ? dwo_units () : normal_units ()) {
716+ if (DWARFTypeUnit *TU = dyn_cast<DWARFTypeUnit>(U.get ()))
717+ (*Units.Map )[TU->getTypeHash ()] = TU;
703718 }
704719 }
705- return nullptr ;
720+
721+ return (*Units.Map )[Hash];
706722}
707723
708724DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash (uint64_t Hash) {
You can’t perform that action at this time.
0 commit comments