[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:14:08 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:

Oh, also, if you kept the result (more like a `llvm::find_if` as @bulbazord was suggesting, rather than my `llvm::none_of` here) of this search, you could save a small amount of time (no need to indirect through the index and reapply relocations to get the CU offset) by using `getCUInedx()` and comparing that to the index you would've found in this search - down on line 139/150

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


More information about the lldb-commits mailing list