summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-10-29 14:30:05 +0000
committerDuncan Sands <baldrick@free.fr>2012-10-29 14:30:05 +0000
commitedece785500ed4420ab6d5052c76c392487f3f88 (patch)
tree1cd1dcc026ea85ffe7963f67ff0cd9d289110b67 /lib/VMCore
parentf578922cbc20bc8792d380405b825f9224567031 (diff)
downloadllvm-edece785500ed4420ab6d5052c76c392487f3f88.tar.gz
llvm-edece785500ed4420ab6d5052c76c392487f3f88.tar.bz2
llvm-edece785500ed4420ab6d5052c76c392487f3f88.tar.xz
Factorize code: rather than duplication the logic in getPointerTypeSizeInBits,
just call getPointerTypeSizeInBits. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/DataLayout.cpp16
1 files changed, 2 insertions, 14 deletions
diff --git a/lib/VMCore/DataLayout.cpp b/lib/VMCore/DataLayout.cpp
index 104e5da057..b847492719 100644
--- a/lib/VMCore/DataLayout.cpp
+++ b/lib/VMCore/DataLayout.cpp
@@ -678,20 +678,8 @@ IntegerType *DataLayout::getIntPtrType(LLVMContext &C,
/// 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 {
- LLVMContext &C = Ty->getContext();
- // For pointers, we return the size for the specific address space.
- if (Ty->isPointerTy()) return IntegerType::get(C, getTypeSizeInBits(Ty));
- // For vector of pointers, we return the size of the address space
- // of the pointer type.
- if (Ty->isVectorTy() && cast<VectorType>(Ty)->getElementType()->isPointerTy())
- return IntegerType::get(C,
- getTypeSizeInBits(cast<VectorType>(Ty)->getElementType()));
- // Otherwise return the address space for the default address space.
- // An example of this occuring is that you want to get the IntPtr
- // for all of the arguments in a function. However, the IntPtr
- // for a non-pointer type cannot be determined by the type, so
- // the default value is used.
- return getIntPtrType(C, 0);
+ unsigned NumBits = getPointerTypeSizeInBits(Ty);
+ return IntegerType::get(Ty->getContext(), NumBits);
}