[llvm-commits] [llvm-gcc-4.2] r69514 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Chris Lattner sabre at nondot.org
Sat Apr 18 23:23:01 PDT 2009


Author: lattner
Date: Sun Apr 19 01:23:01 2009
New Revision: 69514

URL: http://llvm.org/viewvc/llvm-project?rev=69514&view=rev
Log:
GCC's FOR_EACH_CONSTRUCTOR_ELT macro skips over anonymous
bitfield members.  Handle random spacing added by them in
the struct by adding zero bytes.

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

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=69514&r1=69513&r2=69514&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Sun Apr 19 01:23:01 2009
@@ -6932,6 +6932,14 @@
 /// AddFieldToRecordConstant.
 void ConstantLayoutInfo::
 AddBitFieldToRecordConstant(ConstantInt *ValC, uint64_t GCCFieldOffsetInBits) {
+  // If the GCC field starts after our current LLVM field then there must have
+  // been an anonymous bitfield or other thing that shoved it over.  No matter,
+  // just insert some i8 padding until there are bits to fill in.
+  while (GCCFieldOffsetInBits > NextFieldByteStart*8) {
+    ResultElts.push_back(ConstantInt::get(Type::Int8Ty, 0));
+    ++NextFieldByteStart;
+  }
+  
   // If the field is a bitfield, it could partially go in a previously
   // laid out structure member, and may add elements to the end of the currently
   // laid out structure.
@@ -7009,9 +7017,6 @@
     GCCFieldOffsetInBits = NextFieldByteStart*8;
   }
   
-  assert(GCCFieldOffsetInBits == NextFieldByteStart*8 && 
-         "expected no missing bitfields");
-
   APInt Val = ValC->getValue();
 
   // Okay, we know that we're plopping bytes onto the end of the struct.





More information about the llvm-commits mailing list