Skip to content

[llvm][DebugInfo] LLVM adds redundant DW_AT_data_member_location to C++ union members #160708

@Michael137

Description

@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

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 #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.debuginfo

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions