<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 2, 2015 at 4:28 PM, Robinson, Paul <span dir="ltr"><<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">80-bit float isn't the only case where the value-size and storage-size of a type differ. I seem to remember reading on one of these lists, not so long ago,
something from Richard Smith about how the value-size of a bool is 1 bit while its storage size is 8 bits. I've lost the context though, sorry…<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal">| 1) What's the right representation in DWARF?<u></u><u></u></p>
<p class="MsoNormal" style="margin-bottom:12pt">|<br>
| Unfortunately impossible/hard to answer. DWARF is fairly flexible & doesn't dictate "right" answers, as such.<u></u><u></u></p>
</span><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">This time, actually the "right" answer is fairly clear (and in normative text, no less) right there in section 5.1. Use DW_AT_byte_size for the storage size
and DW_AT_bit_size for the value size.</span></p></div></div></blockquote><div><br></div><div>I'm not sure - it seems like a valid interpretation to believe that the value is 128 bits - some of those bits are always zero. (& of course the DWARF spec says <font face="arial, helvetica, sans-serif">"the base type entry /may/ also have", because it's all permissive & stuff)</font></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><a name="150cabe679c1975a__MailEndCompose"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></a></p>
<div style="border-style:none none none solid;border-left-color:blue;border-left-width:1.5pt;padding:0in 0in 0in 4pt">
<div>
<div style="border-style:solid none none;border-top-color:rgb(181,196,223);border-top-width:1pt;padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>David Blaikie via llvm-dev<br>
<b>Sent:</b> Monday, November 02, 2015 4:10 PM<span class=""><br>
<b>To:</b> Keno Fischer<br>
<b>Cc:</b> llvm-dev<br>
</span><b>Subject:</b> Re: [llvm-dev] Representing X86 long double in Debug Info<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">To come back to the original question: Doesn't LLVM know somewhere that x86_fp80 requires 128 bits of storage? (eg: how does it layout the call argument for an x86_fp80 if it's not being passed in a register? How does it layout the stack
containing one of these?)<br>
<br>
I /imagine/ somewhere in LLVM knows about the need for 128 bits of storage for these things, and we should be using that information to cross reference with the debug info.<br>
<br>
(aside: I don't think there's much merit to DWARF consumers to add this extra info - if they've all been surviving without it for this long)<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Mon, Nov 2, 2015 at 2:47 PM, Keno Fischer <<a href="mailto:kfischer@college.harvard.edu" target="_blank">kfischer@college.harvard.edu</a>> wrote:<u></u><u></u></p>
<div>
<p class="MsoNormal">That was essentially part of my question. The DWARF standard says:<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a DW_AT_bit_size and a DW_AT_data_bit_offset attribute, both of whose values are integer
constant values (see Section 2.19). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the
value. Bits that are part of the offset are padding. <u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">which made me think the representation I proposed in the original email might be correct (i.e. an 80bit value, but always stores as 16 bytes).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">As far as I see it, there's 3 questions here:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">1) What's the right representation in DWARF?<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12pt"><br>
Unfortunately impossible/hard to answer. DWARF is fairly flexible & doesn't dictate "right" answers, as such.<u></u><u></u></p>
<div>
<p class="MsoNormal">GCC produces only the byte_size, as Clang/LLVM does. I don't know what GDB (or LLDB, or anything else) would do with the additional bit_size/data_bit_offset. I doubt any of them are designed to do anything with it, at best they'll ignore
it & that'll be fine.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">2) If we think it should be the byte_size/bit_size combination, how do we describe this in IR, because right now, even though the size is in bits, will always emit `DW_AT_byte_size $(size>>3)`<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">3) How would clang describe this in it's TargetInfo<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Just to throw my opinion out there:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">1) Use the DW_AT_bit_size/DW_AT_byte_size <u></u><u></u></p>
</div>
</div>
</blockquote>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">2) Add a new `storage_size` attribute to DIBaseType that is generally equal to size, except in cases like this, where we should have `storage_size = 128, size = 80`<u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Maybe the other way around (so we don't change the semantics of an existing field & have to worry about breaking back compat?) - the new/differently named field should describe the new thing we want to add, the actual functional size (not
sure what to name it, though)?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">3) Have clang set those based on `getLongDoubeSize` (for storage size) and `getLongDoubleFormat` as Reid suggested. This did seem very hacky too me at first as well, but thinking about it again, the format does encode how many semantic
bits there are (because it is needed for correctly constant folding etc.), which is really what we're asking for here.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">However, I personally don't have strong opinions, as long as there's something consistent I can implement in the verifier.<u></u><u></u></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Mon, Nov 2, 2015 at 5:26 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<u></u><u></u></p>
<div>
<p class="MsoNormal">I'm a bit confused by all this - sizeof(long double) is 16 bytes (128 bits). I /think/ that's what we should be describing, even if some of that's essentially padding?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">On Mon, Nov 2, 2015 at 1:04 PM, Reid Kleckner via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
</div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">On Mon, Nov 2, 2015 at 8:38 AM, Adrian Prantl via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="color:rgb(34,34,34)">Looking at the code in clang CGDebugInfo just passes through the width of the type as it is described by the TypeInfo, which in turn is defined by the Target. At the moment I do not understand why an x86_fp80
is reported to be 128 bits wide. (Since it’s a type natively supported by LLVM </span><a href="http://llvm.org/docs/LangRef.html#floating-point-types" target="_blank">http://llvm.org/docs/LangRef.html#floating-point-types</a><span style="color:rgb(34,34,34)"> I
would have expected it to be more like size=80, align=128)</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">This looks like a bug to me and the debug info should describe an x86_fp80 as being 80 bits wide, but I don’t understand the mechanics well enough to decide whether the TypeInfo is wrong here or if we should work around it in CGDebugInfo.<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I think TypeInfo usually describes the answer that sizeof() is supposed to give. sizeof() is typically a multiple of alignment, so if alignof() is 128, sizeof must be 128. Other common alignments are 32 and 64, which makes sizeof() 96 and
128 respectively. In practice, sizeof(long double) is never 80.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Maybe CGDebugInfo should ask TargetInfo::getLongDoubleFormat() what model is in use and generate dwarf accordingly. It's a bit of a hack, so I'm open to better suggestions.<u></u><u></u></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12pt">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div>
</div>
</div>
</blockquote></div><br></div></div>