Index: include/llvm/DataLayout.h =================================================================== --- include/llvm/DataLayout.h (revision 166626) +++ include/llvm/DataLayout.h (working copy) @@ -231,13 +231,14 @@ } /// Layout pointer alignment - unsigned getPointerABIAlignment(unsigned AS) const { + unsigned getPointerABIAlignment(unsigned AS) const { DenseMap::const_iterator val = Pointers.find(AS); if (val == Pointers.end()) { val = Pointers.find(0); } return val->second.ABIAlign; } + /// Return target's alignment for stack-based pointers unsigned getPointerPrefAlignment(unsigned AS) const { DenseMap::const_iterator val = Pointers.find(AS); @@ -246,29 +247,34 @@ } return val->second.PrefAlign; } + /// Layout pointer size - unsigned getPointerSize(unsigned AS) const { + unsigned getPointerSize(unsigned AS) const { DenseMap::const_iterator val = Pointers.find(AS); if (val == Pointers.end()) { val = Pointers.find(0); } return val->second.TypeBitWidth; } + /// Layout pointer size, in bits - unsigned getPointerSizeInBits(unsigned AS) const { + unsigned getPointerSizeInBits(unsigned AS) const { DenseMap::const_iterator val = Pointers.find(AS); if (val == Pointers.end()) { val = Pointers.find(0); } return 8*val->second.TypeBitWidth; } - /// Layout pointer size, in bits, based on the type. + + /// \brief Layout pointer size, in bits, based on the type. + /// /// If this function is called with a pointer type, then /// the type size of the pointer is returned. /// If this function is called with a vector of pointers, /// then the type size of the pointer is returned. - /// Otherwise the type sizeo f a default pointer is returned. - unsigned getPointerTypeSizeInBits(Type* Ty) const; + /// + /// \returns Returns the size in bits of the pointer type. + unsigned getPointerTypeSizeInBits(Type *Ty) const; /// Size examples: /// Index: lib/VMCore/DataLayout.cpp =================================================================== --- lib/VMCore/DataLayout.cpp (revision 166626) +++ lib/VMCore/DataLayout.cpp (working copy) @@ -524,13 +524,13 @@ return OS.str(); } -unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const -{ - if (Ty->isPointerTy()) return getTypeSizeInBits(Ty); - if (Ty->isVectorTy() - && cast(Ty)->getElementType()->isPointerTy()) - return getTypeSizeInBits(cast(Ty)->getElementType()); - return getPointerSizeInBits(0); +unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const { + // If the type is a vector, then use the address + // space of the element pointer type. + if (Ty->isVectorTy()) Ty = Ty->getVectorElementType(); + + // Return the size of the pointer type. + return getPointerSizeInBits(Ty->getPointerAddressSpace()); } uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const {