[llvm-branch-commits] [llvm-gcc-branch] r71110 - /llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp

Bill Wendling isanbard at gmail.com
Wed May 6 13:10:24 PDT 2009


Author: void
Date: Wed May  6 15:10:24 2009
New Revision: 71110

URL: http://llvm.org/viewvc/llvm-project?rev=71110&view=rev
Log:
--- Merging r71105 into '.':
U    gcc/llvm-convert.cpp


Modified:
    llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp?rev=71110&r1=71109&r2=71110&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp Wed May  6 15:10:24 2009
@@ -6809,6 +6809,7 @@
 /// struct constant, change it to make all the implicit padding between elements
 /// be fully explicit.
 void ConstantLayoutInfo::ConvertToPacked() {
+  assert(!StructIsPacked && "Struct is already packed");
   uint64_t EltOffs = 0;
   for (unsigned i = 0, e = ResultElts.size(); i != e; ++i) {
     Constant *Val = ResultElts[i];
@@ -6896,10 +6897,11 @@
   if (LLVMNaturalByteOffset*8 > GCCFieldOffsetInBits) {
     // Switch to packed.
     ConvertToPacked();
-    LLVMNaturalByteOffset = NextFieldByteStart;
-    ValLLVMAlign = 1;
-    assert(LLVMNaturalByteOffset*8 <= GCCFieldOffsetInBits &&
+    assert(NextFieldByteStart*8 <= GCCFieldOffsetInBits &&
            "Packing didn't fix the problem!");
+    
+    // Recurse to add the field after converting to packed.
+    return AddFieldToRecordConstant(Val, GCCFieldOffsetInBits);
   }
 
   // If the LLVM offset is not large enough, we need to insert explicit
@@ -6915,8 +6917,10 @@
     ResultElts.push_back(Constant::getNullValue(FillTy));
 
     NextFieldByteStart = GCCFieldOffsetInBits/8;
-    LLVMNaturalByteOffset
-      = TargetData::RoundUpAlignment(NextFieldByteStart, ValLLVMAlign);
+    
+    // Recurse to add the field.  This handles the case when the LLVM struct
+    // needs to be converted to packed after inserting tail padding.
+    return AddFieldToRecordConstant(Val, GCCFieldOffsetInBits);
   }
 
   // Slap 'Val' onto the end of our ConstantStruct, it must be known to land





More information about the llvm-branch-commits mailing list