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

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 14:01:31 PST 2024


clayborg wrote:


> > 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.
> 
> I'm not sure I understand - what do you mean by "the abbrev codes are not indexed"? Because of LLVM's current output that uses the weird bit fiddling?

The abbreviation codes are not 1 based indexes like they are for .debug_abbrev:
```
  Abbreviations [
    Abbreviation 0x1718 {
      Tag: DW_TAG_subprogram
      DW_IDX_die_offset: DW_FORM_ref4
      DW_IDX_parent: DW_FORM_flag_present
    }
    Abbreviation 0xb18 {
      Tag: DW_TAG_typedef
      DW_IDX_die_offset: DW_FORM_ref4
      DW_IDX_parent: DW_FORM_flag_present
    }
    Abbreviation 0x998 {
      Tag: DW_TAG_structure_type
      DW_IDX_die_offset: DW_FORM_ref4
      DW_IDX_parent: DW_FORM_flag_present
    }
    Abbreviation 0x1218 {
      Tag: DW_TAG_base_type
      DW_IDX_die_offset: DW_FORM_ref4
      DW_IDX_parent: DW_FORM_flag_present
    }
  ]
```

> 
> I'd consider that a bug/suboptimality, and I'd be fine with llvm-dwarfdump devolving to a linear search through abbrevs in the case where the abbrevs are not monotonically increasing.

I was mostly commenting that .debug_abbrev code lookup is O(1) where if we don't use indexes for the abbrev codes we must do some sort of search and if this happens in .debug_abbrev the search is linear. And of course any code that tries to find abbrevs should work (linear or direct access) depending on what the input is. The main point is it is much more efficient to use 1 based indexes since zero is reserved so that we _can_ do effecient lookups. Most of what I was pointing out was around what .debug_abbrev does right and how it is different from what we are doing for .debug_names abbrev codes.




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


More information about the llvm-commits mailing list