Author: dpatel Date: Mon Oct 1 19:43:27 2007 New Revision: 42520 URL: http://llvm.org/viewvc/llvm-project?rev=42520&view=rev Log: If LLVM struct size matches GCC struct size then do not removing trailing 'extra' padding bytes.
Fix http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071001/054142.html 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=42520&r1=42519&r2=42520&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Oct 1 19:43:27 2007 @@ -1185,7 +1185,7 @@ // If this is a Packed struct and ExtraBitsAvailable is not zero then // remove Extra bytes if ExtraBitsAvailable > 8. - void RemoveExtraBytes () { + void RemoveExtraBytes (unsigned GCCTypeSize) { unsigned NoOfBytesToRemove = ExtraBitsAvailable/8; @@ -1195,6 +1195,10 @@ if (NoOfBytesToRemove == 0) return; + unsigned OriginalSize = ElementSizeInBytes.back(); + if (OriginalSize == GCCTypeSize) + return; + const Type *LastType = Elements.back(); unsigned PadBytes = 0; @@ -1216,7 +1220,6 @@ Elements.pop_back(); Elements.push_back(Pad); - unsigned OriginalSize = ElementSizeInBytes.back(); ElementSizeInBytes.pop_back(); ElementSizeInBytes.push_back(OriginalSize - NoOfBytesToRemove); } @@ -1692,12 +1695,12 @@ for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) DecodeStructFields(Field, *Info); - Info->RemoveExtraBytes(); + 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 LLVMStructSize = Info->getSizeAsLLVMStruct(); - uint64_t GCCTypeSize = ((uint64_t)TREE_INT_CST_LOW(TYPE_SIZE(type))+7)/8; if (LLVMStructSize != GCCTypeSize) { assert(LLVMStructSize < GCCTypeSize && _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits