X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTargetData.cpp;h=63b3eaafe1be92361f24e7e388048b3876aef069;hb=2625f9b2e4388a957286063f6c7fe5406fd0ca7a;hp=8ef50a8cee94b506acafdab3366ad0eb874604e0;hpb=59779c56053d150cf93b80bf90f7ae7839f8d219;p=oota-llvm.git diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 8ef50a8cee9..63b3eaafe1b 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -51,14 +51,14 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) { unsigned TyAlign = ST->isPacked() ? 1 : TD.getABITypeAlignment(Ty); // Add padding if necessary to align the data element properly. - if ((StructSize & TyAlign-1) != 0) + if ((StructSize & (TyAlign-1)) != 0) StructSize = TargetData::RoundUpAlignment(StructSize, TyAlign); // Keep track of maximum alignment constraint. StructAlignment = std::max(TyAlign, StructAlignment); MemberOffsets[i] = StructSize; - StructSize += TD.getABITypeSize(Ty); // Consume space for this data item + StructSize += TD.getTypePaddedSize(Ty); // Consume space for this data item } // Empty structures have alignment of 1 byte. @@ -302,14 +302,14 @@ unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType, BestMatchIdx = LargestInt; } else { assert(AlignType == VECTOR_ALIGN && "Unknown alignment type!"); - + // If we didn't find a vector size that is smaller or equal to this type, // then we will end up scalarizing this to its element type. Just return // the alignment of the element. return getAlignment(cast(Ty)->getElementType(), ABIInfo); - } + } } - + // Since we got a "best match" index, just return it. return ABIInfo ? Alignments[BestMatchIdx].ABIAlign : Alignments[BestMatchIdx].PrefAlign; @@ -425,7 +425,7 @@ uint64_t TargetData::getTypeSizeInBits(const Type *Ty) const { return getPointerSizeInBits(); case Type::ArrayTyID: { const ArrayType *ATy = cast(Ty); - return getABITypeSizeInBits(ATy->getElementType())*ATy->getNumElements(); + return getTypePaddedSizeInBits(ATy->getElementType())*ATy->getNumElements(); } case Type::StructTyID: // Get the layout annotation... which is lazily created on demand. @@ -475,12 +475,12 @@ unsigned char TargetData::getAlignment(const Type *Ty, bool abi_or_pref) const { : getPointerPrefAlignment()); case Type::ArrayTyID: return getAlignment(cast(Ty)->getElementType(), abi_or_pref); - + case Type::StructTyID: { // Packed structure types always have an ABI alignment of one. if (cast(Ty)->isPacked() && abi_or_pref) return 1; - + // Get the layout annotation... which is lazily created on demand. const StructLayout *Layout = getStructLayout(cast(Ty)); unsigned Align = getAlignmentInfo(AGGREGATE_ALIGN, 0, abi_or_pref, Ty); @@ -568,7 +568,7 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices, // Get the array index and the size of each array element. int64_t arrayIdx = cast(Indices[CurIDX])->getSExtValue(); - Result += arrayIdx * (int64_t)getABITypeSize(Ty); + Result += arrayIdx * (int64_t)getTypePaddedSize(Ty); } }