aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2006-06-28 01:01:52 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2006-06-28 01:01:52 +0000
commitb8e604c29a720edee8bff5981b0b3dc2b02eb9f0 (patch)
tree0bad89d8704ee23a62db19b1cb94a540df09a620
parentc9094dbbe9557f7cc4e7e094a5901ea2fa680e3d (diff)
Catch more function pointer casting problems
Remove the Function pointer cast in these calls, converting it to a cast of argument. %tmp60 = tail call int cast (int (ulong)* %str to int (int)*)( int 10 ) %tmp60 = tail call int cast (int (ulong)* %str to int (int)*)( uint %tmp51 ) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28953 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index c7fb848802..63cd256dc5 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -6048,7 +6048,15 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
CallSite::arg_iterator AI = CS.arg_begin();
for (unsigned i = 0, e = NumCommonArgs; i != e; ++i, ++AI) {
const Type *ParamTy = FT->getParamType(i);
- bool isConvertible = (*AI)->getType()->isLosslesslyConvertibleTo(ParamTy);
+ const Type *ActTy = (*AI)->getType();
+ ConstantSInt* c = dyn_cast<ConstantSInt>(*AI);
+ //Either we can cast directly, or we can upconvert the argument
+ bool isConvertible = ActTy->isLosslesslyConvertibleTo(ParamTy) ||
+ (ParamTy->isIntegral() && ActTy->isIntegral() &&
+ ParamTy->isSigned() == ActTy->isSigned() &&
+ ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize()) ||
+ (c && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize() &&
+ c->getValue() > 0);
if (Callee->isExternal() && !isConvertible) return false;
}