<html><body><div style="color:#000; background-color:#fff; font-family:tahoma, new york, times, serif;font-size:10pt"><div style="font-family: tahoma, 'new york', times, serif; font-size: 10pt; "><span>So, the problem is that the same approach needs to be applied to the vftable pointer, as well as the vbtable pointer.</span></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><span><br></span></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; ">I have a small diff of changes that pass all my tests... is this good enough to submit? (I'm working against 3.1 but the same is true of the trunk and I can sync to that to submit a patch)</div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color:
transparent; font-style: normal; "><br></div><div style="background-color: transparent; "><div style="background-color: transparent; "><font size="2">Index: lib/AST/RecordLayoutBuilder.cpp</font></div><div style="background-color: transparent; "><font size="2">===================================================================</font></div><div style="background-color: transparent; "><font size="2">--- lib/AST/RecordLayoutBuilder.cpp (revision 162839)</font></div><div style="background-color: transparent; "><font size="2">+++ lib/AST/RecordLayoutBuilder.cpp (working copy)</font></div><div style="background-color: transparent; "><font size="2">@@ -1009,7 +1009,7 @@</font></div><div style="background-color: transparent; "><font size="2"><br></font></div><div style="background-color: transparent; "><font size="2"> // Compute base subobject info.</font></div><div style="background-color: transparent; "><font
size="2"> ComputeBaseSubobjectInfo(RD);</font></div><div style="background-color: transparent; "><font size="2">-</font></div><div style="background-color: transparent; "><font size="2">+</font></div><div style="background-color: transparent; "><font size="2"> // If we have a primary base class, lay it out.</font></div><div style="background-color: transparent; "><font size="2"> if (PrimaryBase) {</font></div><div style="background-color: transparent; "><font size="2"> if (PrimaryBaseIsVirtual) {</font></div><div style="background-color: transparent; "><font size="2">@@ -1044,8 +1044,13 @@</font></div><div style="background-color: transparent; "><font size="2"> CharUnits PtrAlign =</font></div><div style="background-color: transparent; "><font size="2"> Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(0));</font></div><div
style="background-color: transparent; "><font size="2"> EnsureVTablePointerAlignment(PtrAlign);</font></div><div style="background-color: transparent; "><font size="2">- if (isMicrosoftCXXABI())</font></div><div style="background-color: transparent; "><font size="2">+ if (isMicrosoftCXXABI()) {</font></div><div style="background-color: transparent; "><font size="2"> VFPtrOffset = getSize();</font></div><div style="background-color: transparent; "><font size="2">+</font></div><div style="background-color: transparent; "><font size="2">+ // MSVC will extend the width of the vftable pointer to the max width</font></div><div style="background-color: transparent; "><font size="2">+ // of all fields in the record</font></div><div style="background-color: transparent; "><font size="2">+ PtrWidth = std::max(Alignment,
PtrWidth);</font></div><div style="background-color: transparent; "><font size="2">+ }</font></div><div style="background-color: transparent; "><font size="2"> setSize(getSize() + PtrWidth);</font></div><div style="background-color: transparent; "><font size="2"> setDataSize(getSize());</font></div><div style="background-color: transparent; "><font size="2"> }</font></div><div style="background-color: transparent; "><font size="2">@@ -2222,6 +2227,16 @@</font></div><div style="background-color: transparent; "><font size="2"> Builder.Layout(RD);</font></div><div style="background-color: transparent; "><font size="2"> }</font></div><div style="background-color: transparent; "><font size="2"><br></font></div><div style="background-color: transparent; "><font size="2">+ // The same is true in MSVC when there is a vftable
pointer</font></div><div style="background-color: transparent; "><font size="2">+ CharUnits PtrWidth =</font></div><div style="background-color: transparent; "><font size="2">+ toCharUnitsFromBits(getTargetInfo().getPointerWidth(0));</font></div><div style="background-color: transparent; "><font size="2">+ if (Builder.isMicrosoftCXXABI() &&</font></div><div style="background-color: transparent; "><font size="2">+ Builder.VFPtrOffset != CharUnits::fromQuantity(-1) &&</font></div><div style="background-color: transparent; "><font size="2">+ Builder.NonVirtualAlignment.getQuantity() > PtrWidth.getQuantity()) {</font></div><div style="background-color: transparent; "><font size="2">+ Builder.resetWithTargetAlignment(Builder.NonVirtualAlignment);</font></div><div style="background-color: transparent; "><font size="2">+
Builder.Layout(RD);</font></div><div style="background-color: transparent; "><font size="2">+ }</font></div><div style="background-color: transparent; "><font size="2">+</font></div><div style="background-color: transparent; "><font size="2"> // FIXME: This is not always correct. See the part about bitfields at</font></div><div style="background-color: transparent; "><font size="2"> // http://www.codesourcery.com/public/cxx-abi/abi.html#POD for more info.</font></div><div style="background-color: transparent; "><font size="2"> // FIXME: IsPODForThePurposeOfLayout should be stored in the record layout.</font></div></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0,
0, 0); background-color: transparent; font-style: normal; "><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 10pt; "><br></div> <div style="font-family: tahoma, 'new york', times, serif; font-size: 10pt; "> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Don Williamson <don.williamson@yahoo.com><br> <b><span style="font-weight: bold;">To:</span></b> cfe-dev <cfe-dev@cs.uiuc.edu> <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, August 30, 2012 12:07 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [cfe-dev] double/virtual offsets for MSVC broken in 3.1<br> </font> </div> <br>
<meta http-equiv="x-dns-prefetch-control" content="off"><div id="yiv578608269"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif; font-size: 10pt; "><div style="font-size: 10pt; font-family: arial, helvetica, sans-serif; "><span>The change appears to stem from:</span></div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><span><br></span></div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><span><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span></span>http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?r1=143800&r2=144072&diff_format=h</div><div style="color:rgb(0, 0, 0);
background-color:transparent;"><span style="font-family: tahoma, 'new york', times, serif; font-size: 13px; "><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span><span>Revision </span><span style="color:rgb(136, 0, 136);"><a rel="nofollow" target="_blank" href="http://llvm.org/viewvc/llvm-project?view=rev&revision=144072" style="color:rgb(136, 0, 136);">144072</a>, </span>Modified Mon Nov 7 22:01:03 2011 CST (9 months, 3 weeks ago) by rjmccall<span> </span></span></div><div style="color:rgb(0, 0, 0);background-color:transparent;"><span style="font-family: tahoma, 'new york', times, serif; font-size: 13px; "><span><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span></span><span style="white-space:pre-wrap;">Fix the layout of vb-tables and vf-tables in the MS C++ ABI. </span></span><span style="font-family: tahoma, 'new york', times, serif; font-size: 13px; white-space: pre-wrap;
background-color: transparent; ">Based on work by Dmitry
Sokolov!</span></div><div style="color: rgb(0, 0, 0); background-color: transparent; font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal; "><span style="font-family: tahoma, 'new york', times, serif; font-size: 13px; white-space: pre-wrap; background-color: transparent; "><br></span></div><div style="color: rgb(0, 0, 0); background-color: transparent; font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal; "><span style="white-space:pre-wrap;">Trying to figure out what's different...</span></div><div style="color: rgb(0, 0, 0); background-color: transparent; font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal; "><span style="font-family: tahoma, 'new york', times, serif; font-size: 13px; white-space: pre-wrap; background-color: transparent; "><br></span></div><div style="font-size: 10pt; font-family: arial, helvetica, sans-serif; "><br></div> <div
style="font-size: 10pt; font-family: arial, helvetica, sans-serif; "> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Don Williamson <don.williamson@yahoo.com><br> <b><span style="font-weight:bold;">To:</span></b> cfe-dev <cfe-dev@cs.uiuc.edu> <br> <b><span style="font-weight:bold;">Sent:</span></b> Thursday, August 30, 2012 11:26 AM<br> <b><span style="font-weight:bold;">Subject:</span></b> [cfe-dev] double/virtual offsets for MSVC broken in 3.1<br> </font> </div> <br>
<div id="yiv578608269"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif; font-size: 10pt; "><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Hi,</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; ">last year I submitted a patch (commit by somebody else) to solve cases like this:</div><div style="font-family: arial, helvetica, sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><br></div><div style="background-color:transparent;"><div style="background-color:transparent;"><font face="arial, helvetica, sans-serif" size="2"><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span>// The addition of a double anywhere in
this struct forces the vtable ptr to occupy 4 bytes
+ 4 bytes padding in MSVC</font></div><div style="background-color:transparent;"><font face="arial, helvetica, sans-serif" size="2"><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span>struct DoubleInPolymorphicStruct</font></div><div style="background-color:transparent;"><font face="arial, helvetica, sans-serif" size="2"><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span>{</font></div><div style="background-color:transparent;"><font face="arial, helvetica, sans-serif" size="2"><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span>virtual void Empty() { }</font></div><div style="background-color:transparent;"><font face="arial, helvetica, sans-serif" size="2"><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span>int a;</font></div><div style="background-color:transparent;"><font face="arial, helvetica, sans-serif" size="2"><span class="yiv578608269Apple-tab-span"
style="white-space:pre;"> </span>double b;</font></div><div style="background-color:transparent;"><span class="yiv578608269Apple-tab-span" style="font-family: arial, helvetica, sans-serif; font-size: 13px; background-color: transparent; white-space: pre; "> </span><span style="font-family: arial, helvetica, sans-serif; font-size: small; background-color: transparent; ">};</span><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; "><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; ">The offset of a in MSVC is 8 bytes, but clang in MSVC offset calculation mode puts it at 4. The initial posts are here:</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; "><br></div><div style="color:
rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; "><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span>http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016944.html</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; "><span class="yiv578608269Apple-tab-span" style="white-space:pre;"> </span>http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016970.html</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; "><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; ">These changes did not make it into 3.0 but as far as I could tell, did make it into the
trunk. However, I've just sync'ed up to the 3.1 release and this is still a problem.</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; "><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; ">I'm about to go back and take a look and what's broken but it'll take me a couple of hours to settle back into the code again.</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; "><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; ">Meanwhile, could anybody help with any ideas as to what may have changed?</div><div style="color: rgb(0, 0, 0); font-family: arial,
helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; "><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; ">Thanks!</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 13px; font-style: normal; background-color: transparent; ">- Don</div></div></div></div></div><br>_______________________________________________<br>cfe-dev mailing list<br><a rel="nofollow" ymailto="mailto:cfe-dev@cs.uiuc.edu" target="_blank" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br><br><br> </div> </div> </div></div></div><meta http-equiv="x-dns-prefetch-control" content="on"><br>_______________________________________________<br>cfe-dev mailing list<br><a ymailto="mailto:cfe-dev@cs.uiuc.edu"
href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br><br><br> </div> </div> </div></body></html>