[llvm] [LLVM][DWARF] Chnage order for .debug_names abbrev print out (PR #80229)

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 15:35:25 PST 2024


clayborg wrote:

> How's this compare to how we handle .debug_abbrevs? (perhaps we could be sharing some parsing infrastructure, the same as I'm suggesting/hoping we share some generation infrastructure - but even if not shared code, bringing two different implementations into alignment so they do/express things more similarly would be good)

The abbrevs currently makes a DWARFAbbreviationDeclarationSet which contains a `std::vector<DWARFAbbreviationDeclaration> Decls;` and it also maintains a value call `FirstAbbrCode` which is set to UINT32_MAX if the abbrevs were not indexed starting with some number. Compilers like to use 1 and the starting number. Then when we ask for an abbrev from the DWARFAbbreviationDeclarationSet, it sees is `FirstAbbrCode` is not set to UINT32_MAX, and if it isn't it returns a direct access using:
```
return &Decls[AbbrCode - FirstAbbrCode];
```
So O(1) lookups. Else it falls back to a very costly linear search. But most compilers emit the abbrevs with and index so this works well for 99% of the cases.

The DWARFDebugNames::Entry is quite different and stored in a hash map as the abbrev codes are not indexed.

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


More information about the llvm-commits mailing list