summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/DataLayout.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2012-10-21 20:38:03 +0000
committerHal Finkel <hfinkel@anl.gov>2012-10-21 20:38:03 +0000
commit8884dc323f3dc215554a9275bc2f9bebf944e1cf (patch)
treeeafedbe44dc18880f3462fc6cd4ce3e92b4116d1 /llvm/lib/VMCore/DataLayout.cpp
parent720ae09c00f36243e0d91c86255942d1b5a10593 (diff)
downloadbcm5719-llvm-8884dc323f3dc215554a9275bc2f9bebf944e1cf.tar.gz
bcm5719-llvm-8884dc323f3dc215554a9275bc2f9bebf944e1cf.zip
DataLayout should use itself when calculating the size of a vector.
This is important for vectors of pointers because only DataLayout, not the underlying vector type, knows how to calculate the size of the pointers in the vector. Fixes PR14138. llvm-svn: 166401
Diffstat (limited to 'llvm/lib/VMCore/DataLayout.cpp')
-rw-r--r--llvm/lib/VMCore/DataLayout.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/DataLayout.cpp b/llvm/lib/VMCore/DataLayout.cpp
index 3f75069a60a..e6994be257c 100644
--- a/llvm/lib/VMCore/DataLayout.cpp
+++ b/llvm/lib/VMCore/DataLayout.cpp
@@ -559,8 +559,10 @@ uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const {
// only 80 bits contain information.
case Type::X86_FP80TyID:
return 80;
- case Type::VectorTyID:
- return cast<VectorType>(Ty)->getBitWidth();
+ case Type::VectorTyID: {
+ VectorType *VTy = cast<VectorType>(Ty);
+ return VTy->getNumElements()*getTypeSizeInBits(VTy->getElementType());
+ }
default:
llvm_unreachable("DataLayout::getTypeSizeInBits(): Unsupported type");
}
OpenPOWER on IntegriCloud