diff options
Diffstat (limited to 'gnu/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp')
| -rw-r--r-- | gnu/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/gnu/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp b/gnu/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp index 59b3d0ca55a..17f17572a30 100644 --- a/gnu/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp +++ b/gnu/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp @@ -123,7 +123,7 @@ StringRef DWARFUnitIndex::getColumnHeader(DWARFSectionKind DS) { } void DWARFUnitIndex::dump(raw_ostream &OS) const { - if (!Header.NumBuckets) + if (!*this) return; Header.dump(OS); @@ -165,8 +165,25 @@ DWARFUnitIndex::Entry::getOffset() const { const DWARFUnitIndex::Entry * DWARFUnitIndex::getFromOffset(uint32_t Offset) const { for (uint32_t i = 0; i != Header.NumBuckets; ++i) - if (const auto &Contribs = Rows[i].Contributions) - if (Contribs[InfoColumn].Offset == Offset) + if (const auto &Contribs = Rows[i].Contributions) { + const auto &InfoContrib = Contribs[InfoColumn]; + if (InfoContrib.Offset <= Offset && + Offset < (InfoContrib.Offset + InfoContrib.Length)) return &Rows[i]; + } return nullptr; } + +const DWARFUnitIndex::Entry *DWARFUnitIndex::getFromHash(uint64_t S) const { + uint64_t Mask = Header.NumBuckets - 1; + + auto H = S & Mask; + auto HP = ((S >> 32) & Mask) | 1; + while (Rows[H].getSignature() != S && Rows[H].getSignature() != 0) + H = (H + HP) & Mask; + + if (Rows[H].getSignature() != S) + return nullptr; + + return &Rows[H]; +} |
