diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-01 17:32:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-01 17:32:59 +0000 |
commit | 59b006733491dec071d894ad8dc139c292000fd6 (patch) | |
tree | f2f79c892dc9e2fbe8443ac0e8a37b8d7bb0e26f /lib/Target/TargetData.cpp | |
parent | beb5e782013428702392c8be894e29a9a7ae5aea (diff) |
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
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r-- | lib/Target/TargetData.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index caa66fe091..59ef5accd8 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -168,19 +168,19 @@ static inline void getTypeInfo(const Type *Ty, const TargetData *TD, Size = TD->getPointerSize(); Alignment = TD->getPointerAlignment(); return; 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); - Size *= ATy->getNumElements(); + Size = AlignedSize*ATy->getNumElements(); return; } case Type::StructTyID: { // 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; return; } - case Type::TypeTyID: default: assert(0 && "Bad type for getTypeInfo!!!"); return; |