[llvm-commits] [llvm-gcc-4.2] r42551 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Devang Patel
dpatel at apple.com
Tue Oct 2 14:33:23 PDT 2007
Author: dpatel
Date: Tue Oct 2 16:33:22 2007
New Revision: 42551
URL: http://llvm.org/viewvc/llvm-project?rev=42551&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.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=42551&r1=42550&r2=42551&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Tue Oct 2 16:33:22 2007
@@ -1184,7 +1184,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;
@@ -1194,10 +1194,6 @@
if (NoOfBytesToRemove == 0)
return;
- unsigned OriginalSize = ElementSizeInBytes.back();
- if (OriginalSize == GCCTypeSize)
- return;
-
const Type *LastType = Elements.back();
unsigned PadBytes = 0;
@@ -1216,6 +1212,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);
@@ -1694,13 +1691,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!");
@@ -1726,7 +1727,9 @@
}
}
}
- }
+ } else
+ Info->RemoveExtraBytes();
+
// Now that the LLVM struct is finalized, figure out a safe place to index to
// and set index values for each FieldDecl that doesn't start at a variable
More information about the llvm-commits
mailing list