diff options
author | Micah Villmow <villmow@gmail.com> | 2012-10-24 15:52:52 +0000 |
---|---|---|
committer | Micah Villmow <villmow@gmail.com> | 2012-10-24 15:52:52 +0000 |
commit | aa76e9e2cf50af190de90bc778b7f7e42ef9ceff (patch) | |
tree | 5206b0fb0ac695e3ab1c9cf434b5a85195abf336 /lib/VMCore/Instructions.cpp | |
parent | 3575222175b4982f380ff291bb17be67aadc0966 (diff) |
Add in support for getIntPtrType to get the pointer type based on the address space.
This checkin also adds in some tests that utilize these paths and updates some of the
clients.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 13c4a5d257..e9b96d6cd2 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -2120,6 +2120,17 @@ 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: |