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 | 8884dc323f3dc215554a9275bc2f9bebf944e1cf (patch) | |
| tree | eafedbe44dc18880f3462fc6cd4ce3e92b4116d1 /llvm/lib/VMCore/DataLayout.cpp | |
| parent | 720ae09c00f36243e0d91c86255942d1b5a10593 (diff) | |
| download | bcm5719-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.cpp | 6 |
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"); } |

