summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-01 17:32:59 +0000
committerChris Lattner <sabre@nondot.org>2004-07-01 17:32:59 +0000
commit18a08e702d538ab5dba06c15dcfde38b444ab8aa (patch)
treea5fa3263efae617fd4667d181b0c1f4fffa43119
parent3802014c5125b4b3bfe701cb7b46795c093e5884 (diff)
downloadbcm5719-llvm-18a08e702d538ab5dba06c15dcfde38b444ab8aa.tar.gz
bcm5719-llvm-18a08e702d538ab5dba06c15dcfde38b444ab8aa.zip
Handle targets where alignment can be bigger than the size of the data.
Contributed by Vladimir Prus! llvm-svn: 14534
-rw-r--r--llvm/lib/Target/TargetData.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp
index caa66fe0915..59ef5accd8d 100644
--- a/llvm/lib/Target/TargetData.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud