summaryrefslogtreecommitdiff
path: root/lib/VMCore
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
commit3d39fb8a3f0a29468f59456d723ac477fc549c08 (patch)
treefd2a0a131732e9b3117d8495da3619cfd241d778 /lib/VMCore
parent3740e798bc850cd5d40185959801606433b0221f (diff)
downloadllvm-3d39fb8a3f0a29468f59456d723ac477fc549c08.tar.gz
llvm-3d39fb8a3f0a29468f59456d723ac477fc549c08.tar.bz2
llvm-3d39fb8a3f0a29468f59456d723ac477fc549c08.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166401 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/DataLayout.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/VMCore/DataLayout.cpp b/lib/VMCore/DataLayout.cpp
index 3f75069a60..e6994be257 100644
--- a/lib/VMCore/DataLayout.cpp
+++ b/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");
}