Issue 160708
Summary [llvm][DebugInfo] LLVM adds redundant DW_AT_data_member_location to C++ union members
Labels new issue
Assignees
Reporter Michael137
    GCC and LLVM diverge in this. GCC chooses to omit `DW_AT_data_member_location` for union members because it's going to be `0x0` anyway. LLVM still adds the attribute: [Godbolt](https://godbolt.org/z/jvfMj9Ko7)

Here's the LLVM DWARF:
```
0x00000034:     DW_TAG_member
 DW_AT_name	("x")
                  DW_AT_type	(0x00000047 "int")
 DW_AT_decl_file	("/app/example.cpp")
 DW_AT_decl_line	(2)
 DW_AT_data_member_location	(0x00)

0x0000003d:     DW_TAG_member
 DW_AT_name	("y")
                  DW_AT_type	(0x00000047 "int")
                  DW_AT_decl_file	("/app/example.cpp")
 DW_AT_decl_line	(3)
 DW_AT_data_member_location	(0x00)
```

This came up in https://github.com/llvm/llvm-project/pull/159401. LLDB already knows how to handle both cases, so LLVM could choose to omit it. Not sure if the size benefits would be particularly appealing, to warrant the extra complexity. Though if it's just a case of "don't emit DW_AT_data_member_location for union types", that's rather trivial to implement.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to