<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 23, 2014 at 3:55 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Dec 23, 2014, at 3:42 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 23, 2014 at 11:11 AM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Tue Dec 23 13:11:47 2014<br>
New Revision: 224780<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=224780&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=224780&view=rev</a><br>
Log:<br>
DIBuilder: Similar to createPointerType, make createMemberPointerType take<br>
a size and alignment. Several assertions in DwarfDebug rely on all variable<br>
types to report back a size, or to be derived from a type with a size.<br></blockquote><div><br>Are these reasonable assertions?<br></div></div></div></div></div></blockquote><div><br></div></span><div>In my opinion, yes. I added them to sanity-check DW_OP_piece expressions.</div></div></div></blockquote><div><br>Perhaps we don't need to sanity check these? I can sort of see it, but on the other hand we could jsut treat the size in the metadata as being an opaque value used to emit DWARF, not something we should necessarily rely on/care about in any semantic way. (that way the absence of the value in the metadata reflects the absence of the value in the emitted DWARF, etc - simpler model, allows greater flexibility for clients (some LLVM clients might have different languages they want to generate debug info for with different types that they want to include/omit the size from, etc))<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Does this change modify the resulting DWARF? (should we be putting a DW_AT_size on such things? I assume not, but haven't looked/compared/etc)<br></div></div></div></div></div></blockquote><div><br></div></span><div>.. looking.. Actually it does, but that was unintentional. If want to keep the old behavior, we should extend this check to also include member function pointers.</div><div><br></div><div><div>/// constructTypeDIE - Construct derived type die from DIDerivedType.</div><div>void DwarfUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {</div></div><div>  ...</div><div> // Add size if non-zero (derived types might be zero-sized.)</div><div>  if (Size && Tag != dwarf::DW_TAG_pointer_type)</div><div>    addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);</div></div></div></blockquote><div><br>I don't hugely mind adding a special case for member pointers the same as pointer_type that's already there - but I do wonder if it's the right approach (given my reasoning above)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I’ll do that — just to be consistent with the past. Specifying the size of a pointer in DWARF seems redundant as it should be specified by the target; assuming no target we want to support has more than one pointer size. </div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- adrian</div></font></span><div><div class="h5"><div><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Tested in CFE.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/IR/DIBuilder.h<br>
    llvm/trunk/lib/IR/DIBuilder.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=224780&r1=224779&r2=224780&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=224780&r1=224779&r2=224780&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)<br>
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Tue Dec 23 13:11:47 2014<br>
@@ -172,8 +172,12 @@ namespace llvm {<br>
<br>
     /// \brief Create debugging information entry for a pointer to member.<br>
     /// @param PointeeTy Type pointed to by this pointer.<br>
+    /// @param SizeInBits  Size.<br>
+    /// @param AlignInBits Alignment. (optional)<br>
     /// @param Class Type for which this pointer points to members of.<br>
-    DIDerivedType createMemberPointerType(DIType PointeeTy, DIType Class);<br>
+    DIDerivedType createMemberPointerType(DIType PointeeTy, DIType Class,<br>
+                                          uint64_t SizeInBits,<br>
+                                          uint64_t AlignInBits = 0);<br>
<br>
     /// createReferenceType - Create debugging information entry for a c++<br>
     /// style reference or rvalue reference type.<br>
<br>
Modified: llvm/trunk/lib/IR/DIBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=224780&r1=224779&r2=224780&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=224780&r1=224779&r2=224780&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)<br>
+++ llvm/trunk/lib/IR/DIBuilder.cpp Tue Dec 23 13:11:47 2014<br>
@@ -328,14 +328,15 @@ DIBuilder::createPointerType(DIType Poin<br>
   return DIDerivedType(MDNode::get(VMContext, Elts));<br>
 }<br>
<br>
-DIDerivedType DIBuilder::createMemberPointerType(DIType PointeeTy,<br>
-                                                 DIType Base) {<br>
+DIDerivedType<br>
+DIBuilder::createMemberPointerType(DIType PointeeTy, DIType Base,<br>
+                                   uint64_t SizeInBits, uint64_t AlignInBits) {<br>
   // Pointer types are encoded in DIDerivedType format.<br>
   Metadata *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_ptr_to_member_type)<br>
                           .concat(StringRef())<br>
                           .concat(0) // Line<br>
-                          .concat(0) // Size<br>
-                          .concat(0) // Align<br>
+                          .concat(SizeInBits) // Size<br>
+                          .concat(AlignInBits) // Align<br>
                           .concat(0) // Offset<br>
                           .concat(0) // Flags<br>
                           .get(VMContext),<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div>
</div></blockquote></div></div></div><br></div></blockquote></div></div></div>