[PATCH] D42082: Add DWARF for discriminated unions

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 15:21:11 PST 2018


Fair point - if a debugger would benefit from/need this
information/distinction (ie: encoding the invariant union/enum thing needs
special handling in the debugger) rather than adding an extra attribute to
a DW_TAG_struct_type (and encoding the invariant union/enum thing as just a
straight struct_tag without any variant_part/etc) then I think having a
variant_part without a discriminator, etc, is probably a good idea.

IF the distinction isn't needed, yeah, maybe better to just have invariant
enums very differently encoded (no variant_party, etc) than the variant
enums - even though they look similar syntactically.

On Thu, Jan 18, 2018 at 2:44 PM Robinson, Paul <paul.robinson at sony.com>
wrote:

> Well, that would be combining existing DWARF features in a novel way,
> which is what the "permissive" aspect of DWARF is all about.  I'd still
> worry that a debugger would choke on it (although dwarfdump likely would be
> unfazed) but it seems closer to the original Rust construct than trying to
> turn it into a "normal" variant record.  And then all Rust enums would be
> using the same tag, which might be a good thing.
>
> --paulr
>
>
>
> *From:* David Blaikie [mailto:dblaikie at gmail.com]
> *Sent:* Thursday, January 18, 2018 2:29 PM
> *To:* reviews+D42082+public+34a7df3826d543fe at reviews.llvm.org
> *Cc:* ttromey at mozilla.com; echristo at gmail.com; Robinson, Paul;
> aprantl at apple.com; jdevlieghere at apple.com; llvm-commits at lists.llvm.org
> *Subject:* Re: [PATCH] D42082: Add DWARF for discriminated unions
>
>
>
> Any difficulty with modelling this more generally - having a
> DW_TAG_enum_type (DICompositeType) with a member that's a
> DW_TAG_variant_part (probably another DICompositeType?) with the members -
> so it doesn't matter whether there's a discriminator on the enum_type, but
> there can be when needed.
>
>
>
> On Thu, Jan 18, 2018 at 2:26 PM Tom Tromey via Phabricator <
> reviews at reviews.llvm.org> wrote:
>
> tromey added a comment.
>
> Having the DIE shape conform to DWARF seems easy in this patch -- just a
> reordering in `DwarfUnit::constructDiscriminatorDIE`.  However I don't see
> how to nicely support univariant Rust enums; the variant part is triggered
> by having a discriminator, but these objects don't have enumerators.
>
> Maybe one idea would be to have `DIBuilder::createDiscriminatedUnionType`
> use `DW_TAG_variant_part` as its tag, then fix things up when emitting the
> DIEs in DwarfUnit.cpp.  Is that too gross?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D42082
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180118/71695d25/attachment.html>


More information about the llvm-commits mailing list