================
@@ -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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to