[Lldb-commits] [lldb] Remove redundant symbol lookups in IRExecutionUnit::FindInSymbols (PR #102835)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 12 18:32:23 PDT 2024


clayborg wrote:

> I agree that passing some sort of "hint" object to prioritize the search would be a more complete solution, but since this is @DmT021's first contribution to LLVM I think we should merge this change if there are no concerns with the current implementation, and if @DmT021 wants to expand on a more general solution for the `Find...` family of functions he could work on that on a separate patch.

It isn't required, but it really isn't any more work to move the functionality so it can be re-used. I am fine either way, but would ok it right away if we just moved the functionality.

> @clayborg I can see how a module could be used as a hint, but I'm not sure how we'd prioritize lookups using functions or compile unit. The code in `SymTab.cpp` does a binary search to find the symbol, how could we restrict this further by passing a function hint, for example?

For symbol lookups, we would only check the Module. If there is not module, we would just search through the target's image list. If there was a module, then we search it first, and avoid that module if we search the module list just by checking the pointer of the module when iterating over the target's module list. The full symbol context isn't required, but it would be nice to set the precedent that others can duplicate when doing lookups of other kinds.

Type lookups are the ones that can benefit from having a SymbolContext to use as the search context. If we type in an expression that mentions a typename, if would be good to start looking in the current function, then fall back to the compile unit, then fall back to the module, and then fall back to all modules. That would help find the best type when searching, and I believe we do have some code that does something similar, but it is done after getting all of the results back.





https://github.com/llvm/llvm-project/pull/102835


More information about the lldb-commits mailing list