diff options
author | Hal Finkel <hfinkel@anl.gov> | 2012-10-21 20:38:03 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2012-10-21 20:38:03 +0000 |
commit | 3d39fb8a3f0a29468f59456d723ac477fc549c08 (patch) | |
tree | fd2a0a131732e9b3117d8495da3619cfd241d778 /lib/VMCore/DataLayout.cpp | |
parent | 3740e798bc850cd5d40185959801606433b0221f (diff) |
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/DataLayout.cpp')
-rw-r--r-- | lib/VMCore/DataLayout.cpp | 6 |
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"); } |