Assert(FPTy->getElementType()->isFunctionTy(),
"Called function is not pointer to function type!", I);
- FunctionType *FTy = cast<FunctionType>(FPTy->getElementType());
+
+ Assert(FPTy->getElementType() == CS.getFunctionType(),
+ "Called function is not the same type as the call!", I);
+
+ FunctionType *FTy = CS.getFunctionType();
// Verify that the correct number of arguments are being passed
if (FTy->isVarArg())