[all-commits] [llvm/llvm-project] 386f2c: Allow multi-member variants in DWARF (#139300)
Tom Tromey via All-commits
all-commits at lists.llvm.org
Mon May 12 07:55:59 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 386f2ca03bdbcf5d08e5ec417bdad6c3de01acb6
https://github.com/llvm/llvm-project/commit/386f2ca03bdbcf5d08e5ec417bdad6c3de01acb6
Author: Tom Tromey <tromey at adacore.com>
Date: 2025-05-12 (Mon, 12 May 2025)
Changed paths:
M llvm/docs/LangRef.rst
M llvm/include/llvm/IR/DIBuilder.h
M llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
M llvm/lib/IR/DIBuilder.cpp
M llvm/lib/IR/Verifier.cpp
A llvm/test/DebugInfo/Generic/multi-variant.ll
Log Message:
-----------
Allow multi-member variants in DWARF (#139300)
Currently, each variant in the variant part of a structure type can only
contain a single member. This was sufficient for Rust, where each
variant is represented as its own type.
However, this isn't really enough for Ada, where a variant can have
multiple members.
This patch adds support for this scenario. This is done by allowing the
use of DW_TAG_variant by DICompositeType, and then changing the DWARF
generator to recognize when a DIDerivedType representing a variant holds
one of these. In this case, the fields from the DW_TAG_variant are
inlined into the variant, like so:
```
<4><7d>: Abbrev Number: 9 (DW_TAG_variant)
<7e> DW_AT_discr_value : 74
<5><7f>: Abbrev Number: 7 (DW_TAG_member)
<80> DW_AT_name : (indirect string, offset: 0x43): field0
<84> DW_AT_type : <0xa7>
<88> DW_AT_alignment : 8
<89> DW_AT_data_member_location: 0
<5><8a>: Abbrev Number: 7 (DW_TAG_member)
<8b> DW_AT_name : (indirect string, offset: 0x4a): field1
<8f> DW_AT_type : <0xa7>
<93> DW_AT_alignment : 8
<94> DW_AT_data_member_location: 8
```
Note that the intermediate DIDerivedType is still needed in this
situation, because that is where the discriminants are stored.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list