diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-03-06 17:33:55 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-03-06 17:33:55 +0000 |
commit | a236ea551ccf97911bb566850a09c1c72d412152 (patch) | |
tree | a4103d4ad4bdc6384e9a5246f58afd7cdbdd0036 /llvm/lib/IR/Instructions.cpp | |
parent | 9c86656d62eedb7c88c16421680d2be23f72e3d6 (diff) | |
download | bcm5719-llvm-a236ea551ccf97911bb566850a09c1c72d412152.tar.gz bcm5719-llvm-a236ea551ccf97911bb566850a09c1c72d412152.zip |
Teach lint about address spaces
llvm-svn: 203132
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r-- | llvm/lib/IR/Instructions.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index c89365fcda6..c3a34a2ccd7 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -2115,8 +2115,27 @@ bool CastInst::isNoopCast(Type *IntPtrTy) const { 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 +bool CastInst::isNoopCast(const DataLayout *DL) const { + if (!DL) { + // Assume maximum pointer size. + return isNoopCast(Type::getInt64Ty(getContext())); + } + + Type *PtrOpTy = 0; + if (getOpcode() == Instruction::PtrToInt) + PtrOpTy = getOperand(0)->getType(); + else if (getOpcode() == Instruction::IntToPtr) + PtrOpTy = getType(); + + Type *IntPtrTy = PtrOpTy + ? DL->getIntPtrType(PtrOpTy) + : DL->getIntPtrType(getContext(), 0); + + 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: /// * %F = firstOpcode SrcTy %x to MidTy /// * %S = secondOpcode MidTy %F to DstTy |