<div dir="ltr">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)<br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 2, 2015 at 2:47 PM, Keno Fischer <span dir="ltr"><<a href="mailto:kfischer@college.harvard.edu" target="_blank">kfischer@college.harvard.edu</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 dir="ltr">That was essentially part of my question. The DWARF standard says:<div><br></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">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. </blockquote><div><br></div><div>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).</div><div><br></div><div>As far as I see it, there's 3 questions here:</div><div><br></div><div>1) What's the right representation in DWARF?</div></div></blockquote><br class="">Unfortunately impossible/hard to answer. DWARF is fairly flexible & doesn't dictate "right" answers, as such.<br><br><div>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.</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 dir="ltr"><div>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)`</div><div>3) How would clang describe this in it's TargetInfo</div><div><br></div><div>Just to throw my opinion out there:</div><div><br></div><div>1) Use the DW_AT_bit_size/DW_AT_byte_size </div></div></blockquote><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 dir="ltr"><div>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`</div></div></blockquote><div><br></div><div>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)?</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 dir="ltr"><div>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.</div><div><br></div><div>However, I personally don't have strong opinions, as long as there's something consistent I can implement in the verifier.</div></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 2, 2015 at 5:26 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.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 dir="ltr">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?</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Mon, Nov 2, 2015 at 1:04 PM, Reid Kleckner via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></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><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Nov 2, 2015 at 8:38 AM, Adrian Prantl via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</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 style="word-wrap:break-word"><div><div><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><br></div></div><div><br></div><div>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.</div></div></blockquote><div><br></div></span><div>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.</div><div><br></div><div>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.</div></div></div></div>
<br></div></div>_______________________________________________<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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>