[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)
David Blaikie via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 25 12:08:29 PDT 2023
================
@@ -129,8 +129,19 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) {
uint64_t cu_offset = cu.GetOffset();
bool found_entry_for_cu = false;
- for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
- for (DebugNames::NameTableEntry nte: ni) {
+ for (const DebugNames::NameIndex &ni : *m_debug_names_up) {
+ // Check if this name index contains an entry for the given CU.
+ bool cu_matches = false;
+ for (uint32_t i = 0; i < ni.getCUCount(); ++i) {
+ if (ni.getCUOffset(i) == cu_offset) {
----------------
dwblaikie wrote:
If NameIndex exposed the CUOffsets as a range (which seems pretty easy/reasonable for it to do - ah, because it requires potentially applying relocations it'd probably require a custom iterator - maybe a mapped iterator would be adequate & easy to do) then this could be written as:
```
if (llvm::none_of(ni.CUOffsets(), [&](uint64_t off) { return off == cu_offset; }))
continue;
```
I /think/ `CUOffsets()` would look something roughly like this:
```
auto CUOffsets() const {
assert(TU < Hdr.CompUnitCount);
const unsigned SectionOffsetSize = dwarf::getDwarfOffsetByteSize(Hdr.Format);
uint64_t Offset = CUsBase + SectionOffsetSize * CU;
auto R = /* Guess we need some sort of generator to produce the values
[CUsBase, CUsBase+SectionOffsetSize*Hdr.CompUnitCount) in SectionOffsetSize increments...
some enhancement to llvm::seq that takes a stride size would be suitable */
return llvm::map_range(llvm::seq(CUsBase,
[&](uint64_t Offset) {
return Section.AccelSection.getRelocatedValue(SectionOffsetSize, &Offset);
});
}
```
https://github.com/llvm/llvm-project/pull/70231
More information about the lldb-commits
mailing list