mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-06 12:16:59 +00:00
If a long double is in a packed struct, it may be
that there is no padding. llvm-svn: 43691
This commit is contained in:
parent
6c2e7e090b
commit
7c0f410b42
@ -733,7 +733,8 @@ 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) {
|
||||
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 @@ static bool HasPadding(const Type *Ty, const TargetData &TD) {
|
||||
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 @@ static bool HasPadding(const Type *Ty, const TargetData &TD) {
|
||||
}
|
||||
|
||||
} 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user