summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/DataLayout.cpp18
-rw-r--r--lib/VMCore/Instructions.cpp11
-rw-r--r--lib/VMCore/Type.cpp7
3 files changed, 9 insertions, 27 deletions
diff --git a/lib/VMCore/DataLayout.cpp b/lib/VMCore/DataLayout.cpp
index 7c9284f9b8..c127aaba42 100644
--- a/lib/VMCore/DataLayout.cpp
+++ b/lib/VMCore/DataLayout.cpp
@@ -524,14 +524,6 @@ std::string DataLayout::getStringRepresentation() const {
return OS.str();
}
-unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const
-{
- if (Ty->isPointerTy()) return getTypeSizeInBits(Ty);
- if (Ty->isVectorTy()
- && cast<VectorType>(Ty)->getElementType()->isPointerTy())
- return getTypeSizeInBits(cast<VectorType>(Ty)->getElementType());
- return getPointerSizeInBits(0);
-}
uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const {
assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
@@ -679,14 +671,20 @@ IntegerType *DataLayout::getIntPtrType(LLVMContext &C,
/// 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);
+#if 0
+ // FIXME: This assert should always have been here, but the review comments
+ // weren't addressed in time, and now there is lots of code "depending" on
+ // this. Uncomment once this is cleaned up.
+ assert(Ty->isPtrOrPtrVectorTy() &&
+ "Expected a pointer or pointer vector type.");
+#endif
+ unsigned NumBits = getTypeSizeInBits(Ty->getScalarType());
IntegerType *IntTy = IntegerType::get(Ty->getContext(), NumBits);
if (VectorType *VecTy = dyn_cast<VectorType>(Ty))
return VectorType::get(IntTy, VecTy->getNumElements());
return IntTy;
}
-
uint64_t DataLayout::getIndexedOffset(Type *ptrTy,
ArrayRef<Value *> Indices) const {
Type *Ty = ptrTy;
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 39ba4df15b..5d063c980f 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -2120,17 +2120,6 @@ bool CastInst::isNoopCast(Type *IntPtrTy) const {
return isNoopCast(getOpcode(), getOperand(0)->getType(), getType(), IntPtrTy);
}
-/// @brief Determine if a cast is a no-op
-bool CastInst::isNoopCast(const DataLayout &DL) const {
- unsigned AS = 0;
- if (getOpcode() == Instruction::PtrToInt)
- AS = getOperand(0)->getType()->getPointerAddressSpace();
- else if (getOpcode() == Instruction::IntToPtr)
- AS = getType()->getPointerAddressSpace();
- Type *IntPtrTy = DL.getIntPtrType(getContext(), AS);
- return isNoopCast(getOpcode(), getOperand(0)->getType(), getType(), IntPtrTy);
-}
-
/// This function determines if a pair of casts can be eliminated and what
/// opcode should be used in the elimination. This assumes that there are two
/// instructions like this:
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 445e15d388..1bbd2c6cf0 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -215,12 +215,7 @@ unsigned Type::getVectorNumElements() const {
}
unsigned Type::getPointerAddressSpace() const {
- if (isPointerTy())
- return cast<PointerType>(this)->getAddressSpace();
- if (isVectorTy())
- return getSequentialElementType()->getPointerAddressSpace();
- llvm_unreachable("Should never reach here!");
- return 0;
+ return cast<PointerType>(this)->getAddressSpace();
}