[llvm-commits] [127042] If new bit field's starting offset is not at byte boundary

dpatel at apple.com dpatel at apple.com
Tue May 8 11:24:04 PDT 2007


Revision: 127042
Author:   dpatel
Date:     2007-05-08 11:24:04 -0700 (Tue, 08 May 2007)

Log Message:
-----------
If new bit field's starting offset is not at byte boundary
_AND_ the field's starting offset is outside already allocated
bytes for enclosing structure then

- Do not insert PadBytes array if PadBytes are zero.
- Update Field size to count  PadBits.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-types.cpp	2007-05-08 18:09:27 UTC (rev 127041)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp	2007-05-08 18:24:04 UTC (rev 127042)
@@ -1395,15 +1395,18 @@
     } else
       PadBytes = StartOffsetInBits/8-FirstUnallocatedByte;
 
-    const Type *Pad = Type::Int8Ty;
-    if (PadBytes != 1)
-      Pad = ArrayType::get(Pad, PadBytes);
-    Info.addElement(Pad, FirstUnallocatedByte, PadBytes);
+    if (PadBytes) {
+      const Type *Pad = Type::Int8Ty;
+      if (PadBytes != 1)
+        Pad = ArrayType::get(Pad, PadBytes);
+      Info.addElement(Pad, FirstUnallocatedByte, PadBytes);
+    }
+
     FirstUnallocatedByte = StartOffsetInBits/8;
     // This field will use some of the bits from this PadBytes, if
     // starting offset is not at byte boundry.
     if (StartOffsetFromByteBoundry != 0)
-      FieldSizeInBits = PadBits;
+      FieldSizeInBits += PadBits;
   }
 
   // Now, Field starts at FirstUnallocatedByte and everything is aligned.





More information about the llvm-commits mailing list