@@ -1657,31 +1657,15 @@ LowerUnalignedLoadRetParam(SelectionDAG &DAG, SDValue &Chain, uint64_t Offset,
16571657 return RetVal;
16581658}
16591659
1660- static bool shouldConvertToIndirectCall (bool IsVarArg, unsigned ParamCount,
1661- NVPTXTargetLowering::ArgListTy &Args,
1662- const CallBase *CB,
1663- GlobalAddressSDNode *Func) {
1660+ static bool shouldConvertToIndirectCall (const CallBase *CB,
1661+ const GlobalAddressSDNode *Func) {
16641662 if (!Func)
16651663 return false ;
16661664 auto *CalleeFunc = dyn_cast<Function>(Func->getGlobal ());
16671665 if (!CalleeFunc)
16681666 return false ;
16691667
1670- auto ActualReturnType = CalleeFunc->getReturnType ();
1671- if (CB->getType () != ActualReturnType)
1672- return true ;
1673-
1674- if (IsVarArg)
1675- return false ;
1676-
1677- auto ActualNumParams = CalleeFunc->getFunctionType ()->getNumParams ();
1678- if (ParamCount != ActualNumParams)
1679- return true ;
1680- for (const Argument &I : CalleeFunc->args ())
1681- if (I.getType () != Args[I.getArgNo ()].Ty )
1682- return true ;
1683-
1684- return false ;
1668+ return CB->getFunctionType () != CalleeFunc->getFunctionType ();
16851669}
16861670
16871671SDValue NVPTXTargetLowering::LowerCall (TargetLowering::CallLoweringInfo &CLI,
@@ -1998,11 +1982,9 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
19981982 VADeclareParam->getVTList (), DeclareParamOps);
19991983 }
20001984
2001- // If the param count, type of any param, or return type of the callsite
2002- // mismatches with that of the function signature, convert the callsite to an
2003- // indirect call.
2004- bool ConvertToIndirectCall =
2005- shouldConvertToIndirectCall (CLI.IsVarArg , ParamCount, Args, CB, Func);
1985+ // If the type of the callsite does not match that of the function, convert
1986+ // the callsite to an indirect call.
1987+ bool ConvertToIndirectCall = shouldConvertToIndirectCall (CB, Func);
20061988
20071989 // Both indirect calls and libcalls have nullptr Func. In order to distinguish
20081990 // between them we must rely on the call site value which is valid for
0 commit comments