1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

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 )

llvm-svn: 28953
This commit is contained in:
Andrew Lenharth 2006-06-28 01:01:52 +00:00
parent 6572fa9869
commit 764ee8eb29

View File

@ -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;
}