Skip to content

Commit c417f45

Browse files
committed
Remove redundant symbol lookups in IRExecutionUnit::FindInSymbols
When we search for a symbol, we first check if it is in the module_sp of the current SymbolContext, and if not, we check in the target's modules. However, the target's ModuleList also includes the already checked module, which leads to a redundant search in it.
1 parent 3c3df1b commit c417f45

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lldb/source/Expression/IRExecutionUnit.cpp

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

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

790794
ModuleFunctionSearchOptions function_options;
@@ -799,20 +803,21 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
799803
sc_list);
800804
if (auto load_addr = resolver.Resolve(sc_list))
801805
return *load_addr;
802-
}
803806

804-
if (sc.target_sp) {
805-
SymbolContextList sc_list;
806-
sc.target_sp->GetImages().FindFunctions(name, lldb::eFunctionNameTypeFull,
807-
function_options, sc_list);
807+
sc.module_sp->FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny,
808+
sc_list);
808809
if (auto load_addr = resolver.Resolve(sc_list))
809810
return *load_addr;
810811
}
811812

812-
if (sc.target_sp) {
813+
{
813814
SymbolContextList sc_list;
814-
sc.target_sp->GetImages().FindSymbolsWithNameAndType(
815-
name, lldb::eSymbolTypeAny, sc_list);
815+
images.FindFunctions(name, lldb::eFunctionNameTypeFull, function_options,
816+
sc_list);
817+
if (auto load_addr = resolver.Resolve(sc_list))
818+
return *load_addr;
819+
820+
images.FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny, sc_list);
816821
if (auto load_addr = resolver.Resolve(sc_list))
817822
return *load_addr;
818823
}

0 commit comments

Comments
 (0)