[Lldb-commits] [lldb] Remove redundant symbol lookups in IRExecutionUnit::FindInSymbols (PR #102835)
Dmitrii Galimzianov via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 3 07:12:32 PDT 2024
https://github.com/DmT021 updated https://github.com/llvm/llvm-project/pull/102835
>From aad4d1c669f84db462454b96e42fd682ea818720 Mon Sep 17 00:00:00 2001
From: Dmitrii Galimzianov <dmt021 at gmail.com>
Date: Tue, 24 Sep 2024 00:33:43 +0200
Subject: [PATCH] Remove redundant symbol lookups in
IRExecutionUnit::FindInSymbols
---
lldb/source/Expression/IRExecutionUnit.cpp | 29 +++++++++++++++++-----
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index f220704423627d..e6aa8978fe8c34 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -785,6 +785,10 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
return LLDB_INVALID_ADDRESS;
}
+ ModuleList non_local_images = target->GetImages();
+ // We'll process module_sp separately, before the other modules.
+ non_local_images.Remove(sc.module_sp);
+
LoadAddressResolver resolver(target, symbol_was_missing_weak);
ModuleFunctionSearchOptions function_options;
@@ -792,6 +796,11 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
function_options.include_inlines = false;
for (const ConstString &name : names) {
+ // The lookup order here is as follows:
+ // 1) Functions in `sc.module_sp`
+ // 2) Functions in the other modules
+ // 3) Symbols in `sc.module_sp`
+ // 4) Symbols in the other modules
if (sc.module_sp) {
SymbolContextList sc_list;
sc.module_sp->FindFunctions(name, CompilerDeclContext(),
@@ -801,18 +810,26 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
return *load_addr;
}
- if (sc.target_sp) {
+ {
+ SymbolContextList sc_list;
+ non_local_images.FindFunctions(name, lldb::eFunctionNameTypeFull,
+ function_options, sc_list);
+ if (auto load_addr = resolver.Resolve(sc_list))
+ return *load_addr;
+ }
+
+ if (sc.module_sp) {
SymbolContextList sc_list;
- sc.target_sp->GetImages().FindFunctions(name, lldb::eFunctionNameTypeFull,
- function_options, sc_list);
+ sc.module_sp->FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny,
+ sc_list);
if (auto load_addr = resolver.Resolve(sc_list))
return *load_addr;
}
- if (sc.target_sp) {
+ {
SymbolContextList sc_list;
- sc.target_sp->GetImages().FindSymbolsWithNameAndType(
- name, lldb::eSymbolTypeAny, sc_list);
+ non_local_images.FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny,
+ sc_list);
if (auto load_addr = resolver.Resolve(sc_list))
return *load_addr;
}
More information about the lldb-commits
mailing list