Teach lint about address spaces

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203132 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Matt Arsenault
2014-03-06 17:33:55 +00:00
parent d530a96701
commit 38c18efe41
4 changed files with 56 additions and 8 deletions
+21 -2
View File
@@ -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