diff options
| author | Dmitrii Galimzianov <dmt021@gmail.com> | 2024-10-07 22:45:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-07 13:45:27 -0700 |
| commit | d2457e6d8f62a12b3b74791cfd3f5808168c8a71 (patch) | |
| tree | ba5f70e080b4ae54d3429124a0d66c337845eaff /lldb/source/Expression/IRExecutionUnit.cpp | |
| parent | a98466ad8967f9ad9cd79157a7aed8ade5d65a7a (diff) | |
| download | llvm-d2457e6d8f62a12b3b74791cfd3f5808168c8a71.tar.gz llvm-d2457e6d8f62a12b3b74791cfd3f5808168c8a71.tar.bz2 llvm-d2457e6d8f62a12b3b74791cfd3f5808168c8a71.zip | |
Remove redundant symbol lookups in IRExecutionUnit::FindInSymbols (#102835)
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.
Diffstat (limited to 'lldb/source/Expression/IRExecutionUnit.cpp')
| -rw-r--r-- | lldb/source/Expression/IRExecutionUnit.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index baf70cbccc8c..7bee183d2ff2 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -780,6 +780,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; @@ -787,6 +791,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(), @@ -796,18 +805,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; } |
