[PATCH] D42082: Add DWARF for discriminated unions
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 16 10:09:40 PST 2018
dblaikie added a comment.
So, to summarize the changes for myself/others, focusing on the changes to the metadata syntax/semantics (rather than the DIBuilder API changes - though they're equivalent):
- Adds another DIDerivedType field to DICompositeType, null for existing cases, but otherwise holds a reference to a member that is the discriminator
- Uses the 'extra data' in a DIDerivedType member (existing uses include for the constant value in a static member variable, that doesn't overlap with this usage that only applies to non-static members) to hold the constant discriminant value (what value of the discriminator denotes this as the active member)
Any DICompositeType with a non-null discriminator gets emitted with all its member variables wrapped in a DW_TAG_variant & each member other than the discriminator gets a discriminant value.
Seems OK - as noted in the review description, this is not as general as DWARF supports (it allows arbitrary groupings of members into discriminated unions - not just the "all or nothing" provided here), but I'm not sure that matters too much (open to hearing other opinions if folks feel like this is too special-case and would be a pain to generalize later if needed, etc).
Mostly curious to hear design feedback/discussion first, then can dig into the specifics (which shouldn't take long - it's mostly the usual mechanical stuff)
Repository:
rL LLVM
https://reviews.llvm.org/D42082
More information about the llvm-commits
mailing list