diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter.cpp | 16 | ||||
-rw-r--r-- | llvm/lib/Target/TargetData.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 12 |
3 files changed, 14 insertions, 21 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp index 3265a99c05d..4ac8026a1b2 100644 --- a/llvm/lib/CodeGen/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter.cpp @@ -889,11 +889,9 @@ void AsmPrinter::EmitString(const ConstantArray *CVA) const { } /// EmitGlobalConstant - Print a general LLVM constant to the .s file. -/// If Packed is false, pad to the ABI size. -void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) { +void AsmPrinter::EmitGlobalConstant(const Constant *CV) { const TargetData *TD = TM.getTargetData(); - unsigned Size = Packed ? - TD->getTypeStoreSize(CV->getType()) : TD->getABITypeSize(CV->getType()); + unsigned Size = TD->getABITypeSize(CV->getType()); if (CV->isNullValue() || isa<UndefValue>(CV)) { EmitZeros(Size); @@ -903,7 +901,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) { EmitString(CVA); } else { // Not a string. Print the values in successive locations for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i) - EmitGlobalConstant(CVA->getOperand(i), false); + EmitGlobalConstant(CVA->getOperand(i)); } return; } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) { @@ -914,13 +912,13 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) { const Constant* field = CVS->getOperand(i); // Check if padding is needed and insert one or more 0s. - uint64_t fieldSize = TD->getTypeStoreSize(field->getType()); + uint64_t fieldSize = TD->getABITypeSize(field->getType()); uint64_t padSize = ((i == e-1 ? Size : cvsLayout->getElementOffset(i+1)) - cvsLayout->getElementOffset(i)) - fieldSize; sizeSoFar += fieldSize + padSize; - // Now print the actual field value without ABI size padding. - EmitGlobalConstant(field, true); + // Now print the actual field value. + EmitGlobalConstant(field); // Insert padding - this may include padding to increase the size of the // current field up to the ABI size (if the struct is not packed) as well @@ -1066,7 +1064,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) { const VectorType *PTy = CP->getType(); for (unsigned I = 0, E = PTy->getNumElements(); I < E; ++I) - EmitGlobalConstant(CP->getOperand(I), false); + EmitGlobalConstant(CP->getOperand(I)); return; } diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp index 69a8ca902b4..f83adefbee3 100644 --- a/llvm/lib/Target/TargetData.cpp +++ b/llvm/lib/Target/TargetData.cpp @@ -48,10 +48,7 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) { // Loop over each of the elements, placing them in memory... for (unsigned i = 0, e = NumElements; i != e; ++i) { const Type *Ty = ST->getElementType(i); - unsigned TyAlign = ST->isPacked() ? - 1 : TD.getABITypeAlignment(Ty); - uint64_t TySize = ST->isPacked() ? - TD.getTypeStoreSize(Ty) : TD.getABITypeSize(Ty); + unsigned TyAlign = ST->isPacked() ? 1 : TD.getABITypeAlignment(Ty); // Add padding if necessary to align the data element properly... StructSize = (StructSize + TyAlign - 1)/TyAlign * TyAlign; @@ -60,7 +57,7 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) { StructAlignment = std::max(TyAlign, StructAlignment); MemberOffsets[i] = StructSize; - StructSize += TySize; // Consume space for this data item + StructSize += TD.getABITypeSize(Ty); // Consume space for this data item } // Empty structures have alignment of 1 byte. diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index ee80104f108..2db6db754e6 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -737,8 +737,7 @@ void SROA::RewriteBitCastUserOfAlloca(Instruction *BCInst, AllocationInst *AI, /// HasPadding - Return true if the specified type has any structure or /// alignment padding, false otherwise. -static bool HasPadding(const Type *Ty, const TargetData &TD, - bool inPacked = false) { +static bool HasPadding(const Type *Ty, const TargetData &TD) { if (const StructType *STy = dyn_cast<StructType>(Ty)) { const StructLayout *SL = TD.getStructLayout(STy); unsigned PrevFieldBitOffset = 0; @@ -746,7 +745,7 @@ static bool HasPadding(const Type *Ty, const TargetData &TD, unsigned FieldBitOffset = SL->getElementOffsetInBits(i); // Padding in sub-elements? - if (HasPadding(STy->getElementType(i), TD, STy->isPacked())) + if (HasPadding(STy->getElementType(i), TD)) return true; // Check to see if there is any padding between this element and the @@ -770,12 +769,11 @@ static bool HasPadding(const Type *Ty, const TargetData &TD, } } else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { - return HasPadding(ATy->getElementType(), TD, false); + return HasPadding(ATy->getElementType(), TD); } else if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) { - return HasPadding(VTy->getElementType(), TD, false); + return HasPadding(VTy->getElementType(), TD); } - return inPacked ? - false : TD.getTypeSizeInBits(Ty) != TD.getABITypeSizeInBits(Ty); + return TD.getTypeSizeInBits(Ty) != TD.getABITypeSizeInBits(Ty); } /// isSafeStructAllocaToScalarRepl - Check to see if the specified allocation of |