[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 25 12:00:09 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) {
+        cu_matches = true;
+        break;
+      }
+    }
+    if (!cu_matches)
+      continue;
----------------
bulbazord wrote:

It'd be great if we could use some kind of `find_if` instead of manually walking the CU Offsets.

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


More information about the lldb-commits mailing list