[llvm-commits] [llvm] r43691 - /llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Duncan Sands
baldrick at free.fr
Sun Nov 4 16:35:08 PST 2007
Author: baldrick
Date: Sun Nov 4 18:35:07 2007
New Revision: 43691
URL: http://llvm.org/viewvc/llvm-project?rev=43691&view=rev
Log:
If a long double is in a packed struct, it may be
that there is no padding.
Modified:
llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=43691&r1=43690&r2=43691&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Sun Nov 4 18:35:07 2007
@@ -733,7 +733,8 @@
/// HasPadding - Return true if the specified type has any structure or
/// alignment padding, false otherwise.
-static bool HasPadding(const Type *Ty, const TargetData &TD) {
+static bool HasPadding(const Type *Ty, const TargetData &TD,
+ bool inPacked = false) {
if (const StructType *STy = dyn_cast<StructType>(Ty)) {
const StructLayout *SL = TD.getStructLayout(STy);
unsigned PrevFieldBitOffset = 0;
@@ -741,7 +742,7 @@
unsigned FieldBitOffset = SL->getElementOffsetInBits(i);
// Padding in sub-elements?
- if (HasPadding(STy->getElementType(i), TD))
+ if (HasPadding(STy->getElementType(i), TD, STy->isPacked()))
return true;
// Check to see if there is any padding between this element and the
@@ -765,11 +766,12 @@
}
} else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
- return HasPadding(ATy->getElementType(), TD);
+ return HasPadding(ATy->getElementType(), TD, false);
} else if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) {
- return HasPadding(VTy->getElementType(), TD);
+ return HasPadding(VTy->getElementType(), TD, false);
}
- return TD.getTypeSizeInBits(Ty) != TD.getABITypeSizeInBits(Ty);
+ return inPacked ?
+ false : TD.getTypeSizeInBits(Ty) != TD.getABITypeSizeInBits(Ty);
}
/// isSafeStructAllocaToScalarRepl - Check to see if the specified allocation of
More information about the llvm-commits
mailing list