From 46013f40444ead22627d1a0d97293cba7bf76e8e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 6 Jan 2007 19:53:32 +0000 Subject: [PATCH] Fix regressions in InstCombine/call-cast-target.ll and InstCombine/2003-11-13-ConstExprCastCall.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32959 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 9bdf0d8d383..66fbe1482d9 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7208,7 +7208,10 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { // Check to see if we are changing the return type... if (OldRetTy != FT->getReturnType()) { if (Callee->isExternal() && !Caller->use_empty() && - OldRetTy != FT->getReturnType()) + OldRetTy != FT->getReturnType() && + // Conversion is ok if changing from pointer to int of same size. + !(isa(FT->getReturnType()) && + TD->getIntPtrType() == OldRetTy)) return false; // Cannot transform this return value. // If the callsite is an invoke instruction, and the return value is used by @@ -7235,6 +7238,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { ConstantInt *c = dyn_cast(*AI); //Either we can cast directly, or we can upconvert the argument bool isConvertible = ActTy == ParamTy || + (isa(ParamTy) && isa(ActTy)) || (ParamTy->isIntegral() && ActTy->isIntegral() && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize()) || (c && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize() &&