mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
Handle targets where alignment can be bigger than the size of the data.
Contributed by Vladimir Prus! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14534 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -168,19 +168,19 @@ static inline void getTypeInfo(const Type *Ty, const TargetData *TD,
|
|||||||
Size = TD->getPointerSize(); Alignment = TD->getPointerAlignment();
|
Size = TD->getPointerSize(); Alignment = TD->getPointerAlignment();
|
||||||
return;
|
return;
|
||||||
case Type::ArrayTyID: {
|
case Type::ArrayTyID: {
|
||||||
const ArrayType *ATy = (const ArrayType *)Ty;
|
const ArrayType *ATy = cast<ArrayType>(Ty);
|
||||||
|
unsigned AlignedSize = (Size + Alignment - 1)/Alignment*Alignment;
|
||||||
getTypeInfo(ATy->getElementType(), TD, Size, Alignment);
|
getTypeInfo(ATy->getElementType(), TD, Size, Alignment);
|
||||||
Size *= ATy->getNumElements();
|
Size = AlignedSize*ATy->getNumElements();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case Type::StructTyID: {
|
case Type::StructTyID: {
|
||||||
// Get the layout annotation... which is lazily created on demand.
|
// Get the layout annotation... which is lazily created on demand.
|
||||||
const StructLayout *Layout = TD->getStructLayout((const StructType*)Ty);
|
const StructLayout *Layout = TD->getStructLayout(cast<StructType>(Ty));
|
||||||
Size = Layout->StructSize; Alignment = Layout->StructAlignment;
|
Size = Layout->StructSize; Alignment = Layout->StructAlignment;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Type::TypeTyID:
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "Bad type for getTypeInfo!!!");
|
assert(0 && "Bad type for getTypeInfo!!!");
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user