Skip to content

Commit aad4d1c

Browse files
committed
Remove redundant symbol lookups in IRExecutionUnit::FindInSymbols
1 parent 3c3df1b commit aad4d1c

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -785,13 +785,22 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
785785
return LLDB_INVALID_ADDRESS;
786786
}
787787

788+
ModuleList non_local_images = target->GetImages();
789+
// We'll process module_sp separately, before the other modules.
790+
non_local_images.Remove(sc.module_sp);
791+
788792
LoadAddressResolver resolver(target, symbol_was_missing_weak);
789793

790794
ModuleFunctionSearchOptions function_options;
791795
function_options.include_symbols = true;
792796
function_options.include_inlines = false;
793797

794798
for (const ConstString &name : names) {
799+
// The lookup order here is as follows:
800+
// 1) Functions in `sc.module_sp`
801+
// 2) Functions in the other modules
802+
// 3) Symbols in `sc.module_sp`
803+
// 4) Symbols in the other modules
795804
if (sc.module_sp) {
796805
SymbolContextList sc_list;
797806
sc.module_sp->FindFunctions(name, CompilerDeclContext(),
@@ -801,18 +810,26 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
801810
return *load_addr;
802811
}
803812

804-
if (sc.target_sp) {
813+
{
814+
SymbolContextList sc_list;
815+
non_local_images.FindFunctions(name, lldb::eFunctionNameTypeFull,
816+
function_options, sc_list);
817+
if (auto load_addr = resolver.Resolve(sc_list))
818+
return *load_addr;
819+
}
820+
821+
if (sc.module_sp) {
805822
SymbolContextList sc_list;
806-
sc.target_sp->GetImages().FindFunctions(name, lldb::eFunctionNameTypeFull,
807-
function_options, sc_list);
823+
sc.module_sp->FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny,
824+
sc_list);
808825
if (auto load_addr = resolver.Resolve(sc_list))
809826
return *load_addr;
810827
}
811828

812-
if (sc.target_sp) {
829+
{
813830
SymbolContextList sc_list;
814-
sc.target_sp->GetImages().FindSymbolsWithNameAndType(
815-
name, lldb::eSymbolTypeAny, sc_list);
831+
non_local_images.FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny,
832+
sc_list);
816833
if (auto load_addr = resolver.Resolve(sc_list))
817834
return *load_addr;
818835
}

0 commit comments

Comments
 (0)