[Lldb-commits] [lldb] Remove redundant symbol lookups in IRExecutionUnit::FindInSymbols (PR #102835)
Dmitrii Galimzianov via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 23 15:34:10 PDT 2024
https://github.com/DmT021 updated https://github.com/llvm/llvm-project/pull/102835
>From 424b3b74d54b10067155f0ceaeec80c78d2e6aab 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 | 36 ++++++++++++++--------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index f220704423627d..d86f63edb9759e 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 images = target->GetImages();
+ // We'll process module_sp separately, before the other modules.
+ images.Remove(sc.module_sp);
+
LoadAddressResolver resolver(target, symbol_was_missing_weak);
ModuleFunctionSearchOptions function_options;
@@ -792,31 +796,39 @@ 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
+ SymbolContextList sc_list;
if (sc.module_sp) {
- SymbolContextList sc_list;
sc.module_sp->FindFunctions(name, CompilerDeclContext(),
lldb::eFunctionNameTypeFull, function_options,
sc_list);
if (auto load_addr = resolver.Resolve(sc_list))
return *load_addr;
+ sc_list.Clear();
}
- if (sc.target_sp) {
- SymbolContextList sc_list;
- sc.target_sp->GetImages().FindFunctions(name, lldb::eFunctionNameTypeFull,
- function_options, sc_list);
- if (auto load_addr = resolver.Resolve(sc_list))
- return *load_addr;
- }
+ images.FindFunctions(name, lldb::eFunctionNameTypeFull, function_options,
+ sc_list);
+ if (auto load_addr = resolver.Resolve(sc_list))
+ return *load_addr;
+ sc_list.Clear();
- if (sc.target_sp) {
- SymbolContextList sc_list;
- sc.target_sp->GetImages().FindSymbolsWithNameAndType(
- name, lldb::eSymbolTypeAny, sc_list);
+ if (sc.module_sp) {
+ sc.module_sp->FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny,
+ sc_list);
if (auto load_addr = resolver.Resolve(sc_list))
return *load_addr;
+ sc_list.Clear();
}
+ images.FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny, sc_list);
+ if (auto load_addr = resolver.Resolve(sc_list))
+ return *load_addr;
+
lldb::addr_t best_internal_load_address =
resolver.GetBestInternalLoadAddress();
if (best_internal_load_address != LLDB_INVALID_ADDRESS)
More information about the lldb-commits
mailing list