[llvm-commits] [dragonegg] r94904 - /dragonegg/trunk/llvm-types.cpp

Duncan Sands baldrick at free.fr
Sat Jan 30 09:24:50 PST 2010


Author: baldrick
Date: Sat Jan 30 11:24:50 2010
New Revision: 94904

URL: http://llvm.org/viewvc/llvm-project?rev=94904&view=rev
Log:
Port commit 94257 (bwilson) from llvm-gcc:
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:
    dragonegg/trunk/llvm-types.cpp

Modified: dragonegg/trunk/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-types.cpp?rev=94904&r1=94903&r2=94904&view=diff

==============================================================================
--- dragonegg/trunk/llvm-types.cpp (original)
+++ dragonegg/trunk/llvm-types.cpp Sat Jan 30 11:24:50 2010
@@ -1566,7 +1566,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