Revision: 127292 Author: dpatel Date: 2007-05-15 16:46:37 -0700 (Tue, 15 May 2007)
Log Message: ----------- Fix PR 1419 http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070514/049641.html Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-types.cpp Modified: apple-local/branches/llvm/gcc/llvm-types.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-types.cpp 2007-05-15 23:37:35 UTC (rev 127291) +++ apple-local/branches/llvm/gcc/llvm-types.cpp 2007-05-15 23:46:37 UTC (rev 127292) @@ -1245,6 +1245,29 @@ return Info->PaddingElement[index]; } +/// OldTy and NewTy are union members. If they are representing +/// structs then adjust their PaddingElement bits. Padding +/// field in one struct may not be a padding field in another +/// struct. +void adjustPaddingElement(const Type *OldTy, const Type *NewTy) { + + StructTypeConversionInfo *OldInfo = StructTypeInfoMap[OldTy]; + StructTypeConversionInfo *NewInfo = StructTypeInfoMap[NewTy]; + + if (!OldInfo || !NewInfo) + return; + + /// FIXME : Find overlapping padding fields and preserve their + /// isPaddingElement bit. For now, clear all isPaddingElement bits. + for (unsigned i = 0, size = NewInfo->PaddingElement.size(); i != size; ++i) + NewInfo->PaddingElement[i] = false; + + for (unsigned i = 0, size = OldInfo->PaddingElement.size(); i != size; ++i) + OldInfo->PaddingElement[i] = false; + +} + + /// getFieldOffsetInBits - Return the offset (in bits) of a FIELD_DECL in a /// structure. static unsigned getFieldOffsetInBits(tree Field) { @@ -1606,6 +1629,7 @@ const Type *TheTy = ConvertType(TREE_TYPE(Field)); unsigned Size = TD.getTypeSize(TheTy); unsigned Align = TD.getABITypeAlignment(TheTy); + adjustPaddingElement(UnionTy, TheTy); if (UnionTy == 0 || Align > MaxAlign || (MaxAlign == Align && Size > MaxSize)) { UnionTy = TheTy; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits