mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-24 08:24:33 +00:00
If a long double is in a packed struct, it may be
that there is no padding. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43691 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -733,7 +733,8 @@ void SROA::RewriteBitCastUserOfAlloca(Instruction *BCInst, AllocationInst *AI,
|
|||||||
|
|
||||||
/// HasPadding - Return true if the specified type has any structure or
|
/// HasPadding - Return true if the specified type has any structure or
|
||||||
/// alignment padding, false otherwise.
|
/// 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)) {
|
if (const StructType *STy = dyn_cast<StructType>(Ty)) {
|
||||||
const StructLayout *SL = TD.getStructLayout(STy);
|
const StructLayout *SL = TD.getStructLayout(STy);
|
||||||
unsigned PrevFieldBitOffset = 0;
|
unsigned PrevFieldBitOffset = 0;
|
||||||
@ -741,7 +742,7 @@ static bool HasPadding(const Type *Ty, const TargetData &TD) {
|
|||||||
unsigned FieldBitOffset = SL->getElementOffsetInBits(i);
|
unsigned FieldBitOffset = SL->getElementOffsetInBits(i);
|
||||||
|
|
||||||
// Padding in sub-elements?
|
// Padding in sub-elements?
|
||||||
if (HasPadding(STy->getElementType(i), TD))
|
if (HasPadding(STy->getElementType(i), TD, STy->isPacked()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Check to see if there is any padding between this element and the
|
// 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)) {
|
} 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)) {
|
} 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
|
/// isSafeStructAllocaToScalarRepl - Check to see if the specified allocation of
|
||||||
|
Reference in New Issue
Block a user