[llvm-commits] [llvm-gcc-4.2] r94257 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Bob Wilson bob.wilson at apple.com
Fri Jan 22 16:06:30 PST 2010


Author: bwilson
Date: Fri Jan 22 18:06:30 2010
New Revision: 94257

URL: http://llvm.org/viewvc/llvm-project?rev=94257&view=rev
Log:
When adding a bitfield to a struct or union, make sure that the integer type
used to hold the bits does not increase the overall alignment of the
structure.  This affects ARM more commonly than other targets because the
ARM port of GCC defines PCC_BITFIELD_TYPE_MATTERS to be true only when using
the AAPCS ABI.  For APCS, bitfields do not affect the alignment.  This
fixes pr5996.

The testcase that exposed this came from the nightly tests, so I have not
added another one.  I ran GCC's compat tests for arm-apple-darwin with this
patch and did not see any regressions.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=94257&r1=94256&r2=94257&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Fri Jan 22 18:06:30 2010
@@ -1608,7 +1608,8 @@
 
   // Check that the alignment of NewFieldTy won't cause a gap in the structure!
   unsigned ByteAlignment = getTypeAlignment(NewFieldTy);
-  if (FirstUnallocatedByte & (ByteAlignment-1)) {
+  if (FirstUnallocatedByte & (ByteAlignment-1) ||
+      ByteAlignment > getGCCStructAlignmentInBytes()) {
     // Instead of inserting a nice whole field, insert a small array of ubytes.
     NewFieldTy = ArrayType::get(Type::getInt8Ty(Context), (Size+7)/8);
   }





More information about the llvm-commits mailing list