[llvm] [AsmPrinter][DebugNames] Implement DW_IDX_parent entries (PR #77457)

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 14:17:25 PST 2024


felipepiovezan wrote:

Thanks for the example @ayermolo, this works quite will! I will update the PR shortly.

Related to your example -- but unrelated to this PR, as this also happens without any of the commits here --, I noticed that we add multiple accelerator entries for those types, entries with _and without_ unit indices. 
I.e. we add an entry pointing to the _declaration_ present in the CU?
For example:

```
namespace MyNamespace {
struct MyStruct1 {
  char c1;
};
struct MyStruct2 {
  char c2;
};
}

MyNamespace::MyStruct1 gv1;
MyNamespace::MyStruct2 gv2;
```

Compiling with:
```
clang++ -target x86_64 -c two_tus.cpp -g2 -gpubnames -fdebug-types-section -o - | \
llvm-dwarfdump - --debug-names | \
grep MyStruct2 -A14
```

We see:

```
  Bucket 0 [
    Name 1 {
      Hash: 0xE186C022
      String: 0x00000037 "MyStruct2"
      Entry @ 0xc9 {
        Abbrev: 0x26c
        Tag: DW_TAG_structure_type
        DW_IDX_type_unit: 0x01
        DW_IDX_die_offset: 0x00000025
      }
      Entry @ 0xd0 {
        Abbrev: 0x268
        Tag: DW_TAG_structure_type
        DW_IDX_die_offset: 0x00000034
      }
    }
  ]
```

I can't explain why this second entry is added. Looking at the debug-info section, the offset `0x34` is an offset to the declaration inside the CU:

```
0x00000029:   DW_TAG_namespace
                DW_AT_name      ("MyNamespace")

0x0000002b:     DW_TAG_structure_type
                  DW_AT_declaration     (true)
                  DW_AT_signature       (0x8b108ad18e93cb95)

0x00000034:     DW_TAG_structure_type
                  DW_AT_declaration     (true)
                  DW_AT_signature       (0x690ca39e0eeaec8f)

0x0000003d:     NULL
```

But declarations are not supposed to show up in debug-names...




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


More information about the llvm-commits mailing list