[PATCH] Complete Rewrite of CGRecordLayoutBuilder

Yunzhong Gao Yunzhong_Gao at playstation.sony.com
Wed Feb 19 11:27:40 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;
----------------
Warren Hunt wrote:
> 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.
Sounds good. Thanks!


http://llvm-reviews.chandlerc.com/D2795



More information about the cfe-commits mailing list