r213217 - MS ABI: Padding injected between empty vbases doesn't up required align
David Majnemer
david.majnemer at gmail.com
Wed Jul 16 17:55:19 PDT 2014
Author: majnemer
Date: Wed Jul 16 19:55:19 2014
New Revision: 213217
URL: http://llvm.org/viewvc/llvm-project?rev=213217&view=rev
Log:
MS ABI: Padding injected between empty vbases doesn't up required align
Only alignment is changed, not required alignment.
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=213217&r1=213216&r2=213217&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Wed Jul 16 19:55:19 2014
@@ -2615,7 +2615,7 @@ void MicrosoftRecordLayoutBuilder::layou
if ((PreviousBaseLayout && PreviousBaseLayout->hasZeroSizedSubObject() &&
BaseLayout.leadsWithZeroSizedBase()) || HasVtordisp) {
Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize;
- RequiredAlignment = VtorDispAlignment;
+ Alignment = std::max(VtorDispAlignment, Alignment);
}
// Insert the virtual base.
ElementInfo Info = getAdjustedElementInfo(BaseLayout);
Modified: cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp?rev=213217&r1=213216&r2=213217&view=diff
==============================================================================
--- cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp (original)
+++ cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp Wed Jul 16 19:55:19 2014
@@ -598,6 +598,62 @@ struct ND : NC {};
// CHECK-X64-NEXT: | [sizeof=12, align=4
// CHECK-X64-NEXT: | nvsize=8, nvalign=4]
+struct OA {};
+struct OB {};
+struct OC : virtual OA, virtual OB {};
+#pragma pack(push, 1)
+struct OD : OC {};
+#pragma pack(pop)
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct OA (empty)
+// CHECK-NEXT: | [sizeof=1, align=1
+// CHECK-NEXT: | nvsize=0, nvalign=1]
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct OB (empty)
+// CHECK-NEXT: | [sizeof=1, align=1
+// CHECK-NEXT: | nvsize=0, nvalign=1]
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct OC
+// CHECK-NEXT: 0 | (OC vbtable pointer)
+// CHECK-NEXT: 4 | struct OA (virtual base) (empty)
+// CHECK-NEXT: 8 | struct OB (virtual base) (empty)
+// CHECK-NEXT: | [sizeof=8, align=4
+// CHECK-NEXT: | nvsize=4, nvalign=4]
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct OD
+// CHECK-NEXT: 0 | struct OC (base)
+// CHECK-NEXT: 0 | (OC vbtable pointer)
+// CHECK-NEXT: 4 | struct OA (virtual base) (empty)
+// CHECK-NEXT: 8 | struct OB (virtual base) (empty)
+// CHECK-NEXT: | [sizeof=8, align=1
+// CHECK-NEXT: | nvsize=4, nvalign=1]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT: 0 | struct OA (empty)
+// CHECK-X64-NEXT: | [sizeof=1, align=1
+// CHECK-X64-NEXT: | nvsize=0, nvalign=1]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT: 0 | struct OB (empty)
+// CHECK-X64-NEXT: | [sizeof=1, align=1
+// CHECK-X64-NEXT: | nvsize=0, nvalign=1]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT: 0 | struct OC
+// CHECK-X64-NEXT: 0 | (OC vbtable pointer)
+// CHECK-X64-NEXT: 8 | struct OA (virtual base) (empty)
+// CHECK-X64-NEXT: 12 | struct OB (virtual base) (empty)
+// CHECK-X64-NEXT: | [sizeof=16, align=8
+// CHECK-X64-NEXT: | nvsize=8, nvalign=8]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT: 0 | struct OD
+// CHECK-X64-NEXT: 0 | struct OC (base)
+// CHECK-X64-NEXT: 0 | (OC vbtable pointer)
+// CHECK-X64-NEXT: 8 | struct OA (virtual base) (empty)
+// CHECK-X64-NEXT: 12 | struct OB (virtual base) (empty)
+// CHECK-X64-NEXT: | [sizeof=12, align=1
+// CHECK-X64-NEXT: | nvsize=8, nvalign=1]
+
+
+
int a[
sizeof(X)+
sizeof(Y)+
@@ -623,4 +679,5 @@ sizeof(RB3)+
sizeof(RC)+
sizeof(RE)+
sizeof(ND)+
+sizeof(OD)+
0];
More information about the cfe-commits
mailing list