[cfe-commits] r131032 - in /cfe/trunk: lib/AST/RecordLayoutBuilder.cpp test/CodeGen/ms_struct-bitfield-3.c

Fariborz Jahanian fjahanian at apple.com
Fri May 6 15:42:22 PDT 2011


Author: fjahanian
Date: Fri May  6 17:42:22 2011
New Revision: 131032

URL: http://llvm.org/viewvc/llvm-project?rev=131032&view=rev
Log:
In ms_struct structs, Establish a new alignment for a 
non-bitfield following a bitfield if size of their types differ.

Modified:
    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
    cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=131032&r1=131031&r2=131032&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri May  6 17:42:22 2011
@@ -1269,15 +1269,19 @@
       // ignored:
       else if (Context.ZeroBitfieldFollowsNonBitfield(FD, LastFD))
         continue;
+      // FIXME. streamline these conditions into a simple one.
       else if (Context.BitfieldFollowsBitfield(FD, LastFD) ||
-               Context.BitfieldFollowsNoneBitfield(FD, LastFD)) {
-        // Adjacent bit fields are packed into the same 1-, 2-, or
+               Context.BitfieldFollowsNoneBitfield(FD, LastFD) ||
+               Context.NoneBitfieldFollowsBitfield(FD, LastFD)) {
+        // 1) Adjacent bit fields are packed into the same 1-, 2-, or
         // 4-byte allocation unit if the integral types are the same
         // size and if the next bit field fits into the current
         // allocation unit without crossing the boundary imposed by the
         // common alignment requirements of the bit fields.
-        // Also, establish a new alignment for a bitfield following
+        // 2) Establish a new alignment for a bitfield following
         // a non-bitfield if size of their types differ.
+        // 3) Establish a new alignment for a non-bitfield following
+        // a bitfield if size of their types differ.
         std::pair<uint64_t, unsigned> FieldInfo = 
           Context.getTypeInfo(FD->getType());
         uint64_t TypeSize = FieldInfo.first;

Modified: cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c?rev=131032&r1=131031&r2=131032&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c (original)
+++ cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c Fri May  6 17:42:22 2011
@@ -22,3 +22,18 @@
 
 struct_0 test_struct_0 = { 18557917, 17, 3, 0, 80, 6487, 93 };
 static int a[(size_struct_0 == sizeof (struct_0)) -1];
+
+struct _struct_1 {
+  int d;
+  unsigned char a;
+  unsigned short b:7;
+  char c;
+} ATTR;
+
+typedef struct _struct_1 struct_1;
+
+#define size_struct_1 12
+
+struct_1 test_struct_1 = { 18557917, 'a', 3, 'b' };
+
+static int a1[(size_struct_1 == sizeof (struct_1)) -1];





More information about the cfe-commits mailing list