Improve type lookup using .debug_names parent chain (#108907) ## Summary This PR improves `SymbolFileDWARF::FindTypes()` by utilizing the newly added parent chain `DW_IDX_parent` in `.debug_names`. The proposal was originally discussed in [this RFC](https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151). ## Implementation To leverage the parent chain for `SymbolFileDWARF::FindTypes()`, this PR adds a new API: `GetTypesWithQuery` in `DWARFIndex` base class. The API performs the same function as `GetTypes` with additional filtering using `TypeQuery`. Since this only introduces filtering, the callback mechanisms at all call sites remain unchanged. A default implementation is given in `DWARFIndex` class which parses debug info and performs the matching. In the `DebugNameDWARFIndex` override, the parent_contexts in the `TypeQuery` is cross checked with parent chain in `.debug_names` for for much faster filtering before fallback to base implementation for final filtering. Unlike the `GetFullyQualifiedType` API, which fully consumes the `DW_IDX_parent` parent chain for exact matching, these new APIs perform partial subset matching for type/namespace queries. This is necessary to support queries involving anonymous or inline namespaces. For instance, a user might request `NS1::NS2::NS3::Foo`, while the index table's parent chain might contain `NS1::inline_NS2::NS3::Foo`, which would fail exact matching. ## Performance Results In one of our internal target using `.debug_names` + split dwarf. Expanding a "this" pointer in locals view in VSCode: 94s => 48s. (Not sure why I got 94s this time instead of 70s last week). --------- Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.