diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-11-01 08:07:29 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-11-01 08:07:29 +0000 |
commit | ece6c6bb6329748b92403c06ac87f45c43485911 (patch) | |
tree | 6db9d3586fbfc4b362af63c5d5b5a5498fb569e0 /lib/VMCore | |
parent | 86ccc55c82651f91fd6a312c5f6a4b511bcd1aec (diff) | |
download | external_llvm-ece6c6bb6329748b92403c06ac87f45c43485911.zip external_llvm-ece6c6bb6329748b92403c06ac87f45c43485911.tar.gz external_llvm-ece6c6bb6329748b92403c06ac87f45c43485911.tar.bz2 |
Revert the series of commits starting with r166578 which introduced the
getIntPtrType support for multiple address spaces via a pointer type,
and also introduced a crasher bug in the constant folder reported in
PR14233.
These commits also contained several problems that should really be
addressed before they are re-committed. I have avoided reverting various
cleanups to the DataLayout APIs that are reasonable to have moving
forward in order to reduce the amount of churn, and minimize the number
of commits that were reverted. I've also manually updated merge
conflicts and manually arranged for the getIntPtrType function to stay
in DataLayout and to be defined in a plausible way after this revert.
Thanks to Duncan for working through this exact strategy with me, and
Nick Lewycky for tracking down the really annoying crasher this
triggered. (Test case to follow in its own commit.)
After discussing with Duncan extensively, and based on a note from
Micah, I'm going to continue to back out some more of the more
problematic patches in this series in order to ensure we go into the
LLVM 3.2 branch with a reasonable story here. I'll send a note to
llvmdev explaining what's going on and why.
Summary of reverted revisions:
r166634: Fix a compiler warning with an unused variable.
r166607: Add some cleanup to the DataLayout changes requested by
Chandler.
r166596: Revert "Back out r166591, not sure why this made it through
since I cancelled the command. Bleh, sorry about this!
r166591: Delete a directory that wasn't supposed to be checked in yet.
r166578: Add in support for getIntPtrType to get the pointer type based
on the address space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167221 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/DataLayout.cpp | 18 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 11 | ||||
-rw-r--r-- | lib/VMCore/Type.cpp | 7 |
3 files changed, 9 insertions, 27 deletions
diff --git a/lib/VMCore/DataLayout.cpp b/lib/VMCore/DataLayout.cpp index 7c9284f..c127aab 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 39ba4df..5d063c9 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 445e15d..1bbd2c6 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(); } |