diff options
Diffstat (limited to 'lib/VMCore/DataLayout.cpp')
-rw-r--r-- | lib/VMCore/DataLayout.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/VMCore/DataLayout.cpp b/lib/VMCore/DataLayout.cpp index b847492719..7c9284f9b8 100644 --- a/lib/VMCore/DataLayout.cpp +++ b/lib/VMCore/DataLayout.cpp @@ -668,18 +668,22 @@ unsigned DataLayout::getPreferredTypeAlignmentShift(Type *Ty) const { return Log2_32(Align); } -/// getIntPtrType - Return an integer type that is the same size or -/// greater to the pointer size for the address space. +/// getIntPtrType - Return an integer type with size at least as big as that +/// of a pointer in the given address space. IntegerType *DataLayout::getIntPtrType(LLVMContext &C, unsigned AddressSpace) const { return IntegerType::get(C, getPointerSizeInBits(AddressSpace)); } -/// getIntPtrType - Return an integer type that is the same size or -/// greater to the pointer size of the specific PointerType. -IntegerType *DataLayout::getIntPtrType(Type *Ty) const { +/// getIntPtrType - Return an integer (vector of integer) type with size at +/// least as big as that of a pointer of the given pointer (vector of pointer) +/// type. +Type *DataLayout::getIntPtrType(Type *Ty) const { unsigned NumBits = getPointerTypeSizeInBits(Ty); - return IntegerType::get(Ty->getContext(), NumBits); + IntegerType *IntTy = IntegerType::get(Ty->getContext(), NumBits); + if (VectorType *VecTy = dyn_cast<VectorType>(Ty)) + return VectorType::get(IntTy, VecTy->getNumElements()); + return IntTy; } |