[llvm-commits] [llvm] r166926 - /llvm/trunk/lib/VMCore/DataLayout.cpp

Duncan Sands baldrick at free.fr
Mon Oct 29 07:30:05 PDT 2012


Author: baldrick
Date: Mon Oct 29 09:30:05 2012
New Revision: 166926

URL: http://llvm.org/viewvc/llvm-project?rev=166926&view=rev
Log:
Factorize code: rather than duplication the logic in getPointerTypeSizeInBits,
just call getPointerTypeSizeInBits.  No functionality change.

Modified:
    llvm/trunk/lib/VMCore/DataLayout.cpp

Modified: llvm/trunk/lib/VMCore/DataLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DataLayout.cpp?rev=166926&r1=166925&r2=166926&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/DataLayout.cpp (original)
+++ llvm/trunk/lib/VMCore/DataLayout.cpp Mon Oct 29 09:30:05 2012
@@ -678,20 +678,8 @@
 /// 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);
 }
 
 





More information about the llvm-commits mailing list