r206087 - [MS-ABI] Fixed alias-avoidance padding in the presence of vtordisps
Warren Hunt
whunt at google.com
Fri Apr 11 16:33:35 PDT 2014
Author: whunt
Date: Fri Apr 11 18:33:35 2014
New Revision: 206087
URL: http://llvm.org/viewvc/llvm-project?rev=206087&view=rev
Log:
[MS-ABI] Fixed alias-avoidance padding in the presence of vtordisps
If a vtordisp exists between two bases, then there is no need for
additional alias avoidance padding. Test case included.
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206087&r1=206086&r2=206087&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Apr 11 18:33:35 2014
@@ -2620,10 +2620,7 @@ void MicrosoftRecordLayoutBuilder::layou
// bytes (in both 32 and 64 bits modes) and always involves rounding up to
// the required alignment, we don't know why.
if (PreviousBaseLayout && PreviousBaseLayout->hasZeroSizedSubObject() &&
- BaseLayout.leadsWithZeroSizedBase())
- Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize;
- // Insert the vtordisp.
- if (HasVtordisp)
+ BaseLayout.leadsWithZeroSizedBase() || HasVtordisp)
Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize;
// Insert the virtual base.
ElementInfo Info = getAdjustedElementInfo(BaseLayout);
Modified: cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp?rev=206087&r1=206086&r2=206087&view=diff
==============================================================================
--- cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp (original)
+++ cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp Fri Apr 11 18:33:35 2014
@@ -547,7 +547,37 @@ struct RZ8 : RX8, RY {};
// CHECK-X64-NEXT: | [sizeof=16, align=8
// CHECK-X64-NEXT: | nvsize=8, nvalign=8]
+struct JA {};
+struct JB {};
+struct JC : JA { virtual void f() {} };
+struct JD : virtual JB, virtual JC { virtual void f() {} JD() {} };
+// CHECK: *** Dumping AST Record Layout
+// CHECK: *** Dumping AST Record Layout
+// CHECK: *** Dumping AST Record Layout
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct JD
+// CHECK-NEXT: 0 | (JD vbtable pointer)
+// CHECK-NEXT: 4 | struct JB (virtual base) (empty)
+// CHECK-NEXT: 4 | (vtordisp for vbase JC)
+// CHECK-NEXT: 8 | struct JC (virtual base)
+// CHECK-NEXT: 8 | (JC vftable pointer)
+// CHECK-NEXT: 12 | struct JA (base) (empty)
+// CHECK-NEXT: | [sizeof=12, align=4
+// CHECK-NEXT: | nvsize=4, nvalign=4]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT: 0 | struct JD
+// CHECK-X64-NEXT: 0 | (JD vbtable pointer)
+// CHECK-X64-NEXT: 8 | struct JB (virtual base) (empty)
+// CHECK-X64-NEXT: 12 | (vtordisp for vbase JC)
+// CHECK-X64-NEXT: 16 | struct JC (virtual base)
+// CHECK-X64-NEXT: 16 | (JC vftable pointer)
+// CHECK-X64-NEXT: 24 | struct JA (base) (empty)
+// CHECK-X64-NEXT: | [sizeof=24, align=8
+// CHECK-X64-NEXT: | nvsize=8, nvalign=8]
int a[
sizeof(AT3) +
@@ -565,4 +595,5 @@ sizeof(RZ5) +
sizeof(RZ6) +
sizeof(RZ7) +
sizeof(RZ8) +
+sizeof(JD) +
0];
More information about the cfe-commits
mailing list