[PATCH] Complete Rewrite of CGRecordLayoutBuilder
Warren Hunt
whunt at google.com
Wed Feb 19 11:19:24 PST 2014
================
Comment at: lib/CodeGen/CGRecordLayoutBuilder.cpp:527
@@ -867,31 +526,3 @@
continue;
- }
-
- if (!LayoutField(FD, Layout.getFieldOffset(FieldNo))) {
- assert(!Packed &&
- "Could not layout fields even with a packed LLVM struct!");
- return false;
- }
- }
-
- if (RD) {
- // We've laid out the non-virtual bases and the fields, now compute the
- // non-virtual base field types.
- if (!ComputeNonVirtualBaseType(RD)) {
- assert(!Packed && "Could not layout even with a packed LLVM struct!");
- return false;
- }
-
- // Lay out the virtual bases. The MS ABI uses a different
- // algorithm here due to the lack of primary virtual bases.
- if (Types.getTarget().getCXXABI().hasPrimaryVBases()) {
- RD->getIndirectPrimaryBases(IndirectPrimaryBases);
- if (Layout.isPrimaryBaseVirtual())
- IndirectPrimaryBases.insert(Layout.getPrimaryBase());
-
- if (!LayoutVirtualBases(RD, Layout))
- return false;
- } else {
- if (!MSLayoutVirtualBases(RD, Layout))
- return false;
- }
+ if (Member->Offset % getAlignment(Member->Data))
+ Packed = true;
----------------
I'll go ahead an add a comment to the code.
If any member falls at an offset that it not a multiple of its alignment, then the entire record must be packed.
================
Comment at: lib/CodeGen/CGRecordLayoutBuilder.cpp:531
@@ -898,6 +530,3 @@
}
-
- // Append tail padding if necessary.
- AppendTailPadding(Layout.getSize());
-
- return true;
+ if (Members.back().Offset % Alignment)
+ Packed = true;
----------------
If the size of the record (the capstone's offset) is not a multiple of the record's alignment, it must be packed.
http://llvm-reviews.chandlerc.com/D2795
More information about the cfe-commits
mailing list