summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-22 05:17:15 +0000
committerChris Lattner <sabre@nondot.org>2009-10-22 05:17:15 +0000
commit63d2b3615cb6c732cb64a00f0fe17cdbeeb1c616 (patch)
tree70e5dfdad7ce4fb3e0af9f57cc821e37b16000ad /clang/lib
parent5457a96b6329538aafb439471235a54f37b0af4a (diff)
downloadbcm5719-llvm-63d2b3615cb6c732cb64a00f0fe17cdbeeb1c616.tar.gz
bcm5719-llvm-63d2b3615cb6c732cb64a00f0fe17cdbeeb1c616.zip
fix PR5265: the size of a float3 should be rounded up to its alignment.
This ensures that arrays of float3 are correctly padded. llvm-svn: 84833
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 442714a5a64..7d9bc0f4725 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -582,14 +582,16 @@ ASTContext::getTypeInfo(const Type *T) {
}
case Type::ExtVector:
case Type::Vector: {
- std::pair<uint64_t, unsigned> EltInfo =
- getTypeInfo(cast<VectorType>(T)->getElementType());
- Width = EltInfo.first*cast<VectorType>(T)->getNumElements();
+ const VectorType *VT = cast<VectorType>(T);
+ std::pair<uint64_t, unsigned> EltInfo = getTypeInfo(VT->getElementType());
+ Width = EltInfo.first*VT->getNumElements();
Align = Width;
// If the alignment is not a power of 2, round up to the next power of 2.
// This happens for non-power-of-2 length vectors.
- // FIXME: this should probably be a target property.
- Align = 1 << llvm::Log2_32_Ceil(Align);
+ if (VT->getNumElements() & (VT->getNumElements()-1)) {
+ Align = llvm::NextPowerOf2(Align);
+ Width = llvm::RoundUpToAlignment(Width, Align);
+ }
break;
}
@@ -748,14 +750,13 @@ ASTContext::getTypeInfo(const Type *T) {
break;
}
- case Type::SubstTemplateTypeParm: {
+ case Type::SubstTemplateTypeParm:
return getTypeInfo(cast<SubstTemplateTypeParmType>(T)->
getReplacementType().getTypePtr());
- }
- case Type::Elaborated: {
- return getTypeInfo(cast<ElaboratedType>(T)->getUnderlyingType().getTypePtr());
- }
+ case Type::Elaborated:
+ return getTypeInfo(cast<ElaboratedType>(T)->getUnderlyingType()
+ .getTypePtr());
case Type::Typedef: {
const TypedefDecl *Typedef = cast<TypedefType>(T)->getDecl();
OpenPOWER on IntegriCloud