Skip to content

Remove redundant symbol lookups in IRExecutionUnit::FindInSymbols #102835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions lldb/source/Expression/IRExecutionUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,13 +785,22 @@ 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;
function_options.include_symbols = true;
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(),
Expand All @@ -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;
}
Expand Down
Loading