Author: dpatel Date: Tue Oct 2 16:28:44 2007 New Revision: 42550 URL: http://llvm.org/viewvc/llvm-project?rev=42550&view=rev Log: Remove extra bytes from LLVMStruct only if is bigger than GCC struct. This patch fixes gcc assertion failure caused by previous patch.
Modified: llvm-gcc-4.0/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.0/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-types.cpp?rev=42550&r1=42549&r2=42550&view=diff ============================================================================== --- llvm-gcc-4.0/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.0/trunk/gcc/llvm-types.cpp Tue Oct 2 16:28:44 2007 @@ -1160,7 +1160,7 @@ // If this is a Packed struct and ExtraBitsAvailable is not zero then // remove Extra bytes if ExtraBitsAvailable > 8. - void RemoveExtraBytes (unsigned GCCTypeSize) { + void RemoveExtraBytes () { unsigned NoOfBytesToRemove = ExtraBitsAvailable/8; @@ -1170,10 +1170,6 @@ if (NoOfBytesToRemove == 0) return; - unsigned OriginalSize = ElementSizeInBytes.back(); - if (OriginalSize == GCCTypeSize) - return; - const Type *LastType = Elements.back(); unsigned PadBytes = 0; @@ -1192,6 +1188,7 @@ // Update last element type and size, element offset is unchanged. const Type *Pad = ArrayType::get(Type::Int8Ty, PadBytes); + unsigned OriginalSize = ElementSizeInBytes.back(); Elements.pop_back(); Elements.push_back(Pad); @@ -1670,13 +1667,17 @@ for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) DecodeStructFields(Field, *Info); - uint64_t GCCTypeSize = ((uint64_t)TREE_INT_CST_LOW(TYPE_SIZE(type))+7)/8; - Info->RemoveExtraBytes(GCCTypeSize); // If the LLVM struct requires explicit tail padding to be the same size as // the GCC struct, insert tail padding now. This handles, e.g., "{}" in C++. if (TYPE_SIZE(type) && TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST) { + uint64_t GCCTypeSize = ((uint64_t)TREE_INT_CST_LOW(TYPE_SIZE(type))+7)/8; uint64_t LLVMStructSize = Info->getSizeAsLLVMStruct(); - + + if (LLVMStructSize > GCCTypeSize) { + Info->RemoveExtraBytes(); + LLVMStructSize = Info->getSizeAsLLVMStruct(); + } + if (LLVMStructSize != GCCTypeSize) { assert(LLVMStructSize < GCCTypeSize && "LLVM type size doesn't match GCC type size!"); @@ -1702,7 +1703,9 @@ } } } - } + } else + Info->RemoveExtraBytes(); + // Now that the LLVM struct is finalized, figure out a safe place to index to // and set the DECL_LLVM values for each FieldDecl that doesn't start at a _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits