Fix isEliminableCastPair to work correctly in the presence of pointers

with different sizes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167018 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands
2012-10-30 16:03:32 +00:00
parent 92b469971e
commit 446cf94cdb
5 changed files with 61 additions and 13 deletions

View File

@@ -87,9 +87,13 @@ foldConstantCastPair(
Instruction::CastOps firstOp = Instruction::CastOps(Op->getOpcode());
Instruction::CastOps secondOp = Instruction::CastOps(opc);
// Assume that pointers are never more than 64 bits wide.
IntegerType *FakeIntPtrTy = Type::getInt64Ty(DstTy->getContext());
// Let CastInst::isEliminableCastPair do the heavy lifting.
return CastInst::isEliminableCastPair(firstOp, secondOp, SrcTy, MidTy, DstTy,
Type::getInt64Ty(DstTy->getContext()));
FakeIntPtrTy, FakeIntPtrTy,
FakeIntPtrTy);
}
static Constant *FoldBitCast(Constant *V, Type *DestTy) {