[Lldb-commits] [lldb] Improve type and namespace lookup using parent chain (PR #108907)

via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 19 14:11:38 PDT 2024


================
@@ -374,25 +377,40 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
   m_fallback.GetFullyQualifiedType(context, callback);
 }
 
+bool DebugNamesDWARFIndex::SameAsEntryATName(
+    llvm::StringRef query_name, const DebugNames::Entry &entry) const {
+  auto maybe_dieoffset = entry.getDIEUnitOffset();
+  if (!maybe_dieoffset)
+    return false;
+
+  // [Optimization] instead of parsing the entry from dwo file, we simply
+  // check if the query_name can point to an entry of the same DIE offset.
+  // This greatly reduced number of dwo file parsed and thus improved the
+  // performance.
+  for (const DebugNames::Entry &query_entry :
+       entry.getNameIndex()->equal_range(query_name)) {
+    auto query_dieoffset = query_entry.getDIEUnitOffset();
+    if (!query_dieoffset)
+      continue;
+
+    if (*query_dieoffset == *maybe_dieoffset) {
+      return true;
+    } else if (*query_dieoffset > *maybe_dieoffset) {
+      // The pool entries of the same name are sequentially cluttered together
+      // so if the query name from `query_name` is after the target entry, this
+      // is definitely not the correct one, we can stop searching.
----------------
jeffreytan81 wrote:

@labath, @felipepiovezan, this assumption (pool entries of the same name are sequentially cluttered together) is actually guaranteed by dwarf5 specification:

Page 141:
```
The entry pool contains all the index entries, grouped by name. The second column of the name list points to the first index entry for the name, and all the index entries for that name are placed one after the other.
```

Also in `6.1.1.4.8 Entry Pool`:

```
Gaps are not allowed between entries in a series (that is, the entries for a single
10 name must all be contiguous), but there may be gaps between series.
```

I can add quoting of these sections in the comment if you think will make it clear. 


https://github.com/llvm/llvm-project/pull/108907


More information about the lldb-commits mailing list