<div dir="ltr">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.<br><br>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.<div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 18, 2018 at 2:44 PM Robinson, Paul <<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div class="m_-4624792513571859455m_-8793248906951235929WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">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.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><a name="m_-4624792513571859455_m_-8793248906951235929__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>]
<br>
<b>Sent:</b> Thursday, January 18, 2018 2:29 PM<br>
<b>To:</b> <a href="mailto:reviews%2BD42082%2Bpublic%2B34a7df3826d543fe@reviews.llvm.org" target="_blank">reviews+D42082+public+34a7df3826d543fe@reviews.llvm.org</a><br>
<b>Cc:</b> <a href="mailto:ttromey@mozilla.com" target="_blank">ttromey@mozilla.com</a>; <a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>; Robinson, Paul; <a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>; <a href="mailto:jdevlieghere@apple.com" target="_blank">jdevlieghere@apple.com</a>; <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<b>Subject:</b> Re: [PATCH] D42082: Add DWARF for discriminated unions<u></u><u></u></span></p>
</div>
</div></div></div></div><div lang="EN-US" link="blue" vlink="purple"><div class="m_-4624792513571859455m_-8793248906951235929WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">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.<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Thu, Jan 18, 2018 at 2:26 PM Tom Tromey via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal" style="margin-bottom:12.0pt">tromey added a comment.<br>
<br>
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.<br>
<br>
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?<br>
<br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D42082" target="_blank">https://reviews.llvm.org/D42082</a><br>
<br>
<br>
<u></u><u></u></p>
</blockquote>
</div>
</div></div></div></blockquote></div></div></div>