@@ -112,16 +112,9 @@ namespace {
112
112
public:
113
113
HexagonCCState (CallingConv::ID CC, bool IsVarArg, MachineFunction &MF,
114
114
SmallVectorImpl<CCValAssign> &locs, LLVMContext &C,
115
- const Function *Callee)
116
- : CCState(CC, IsVarArg, MF, locs, C) {
117
- // If a function has zero args and is a vararg function, that's
118
- // disallowed so it must be an undeclared function. Do not assume
119
- // varargs if the callee is undefined.
120
- if (Callee && Callee->isVarArg () &&
121
- Callee->getFunctionType ()->getNumParams () != 0 )
122
- NumNamedVarArgParams = Callee->getFunctionType ()->getNumParams ();
123
- }
124
-
115
+ unsigned NumNamedArgs)
116
+ : CCState(CC, IsVarArg, MF, locs, C),
117
+ NumNamedVarArgParams (NumNamedArgs) {}
125
118
unsigned getNumNamedVarArgParams () const { return NumNamedVarArgParams; }
126
119
};
127
120
@@ -324,22 +317,21 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
324
317
bool IsVarArg = CLI.IsVarArg ;
325
318
bool DoesNotReturn = CLI.DoesNotReturn ;
326
319
327
- bool IsStructRet = ( Outs.empty () ) ? false : Outs[0 ].Flags .isSRet ();
320
+ bool IsStructRet = Outs.empty () ? false : Outs[0 ].Flags .isSRet ();
328
321
MachineFunction &MF = DAG.getMachineFunction ();
329
322
MachineFrameInfo &MFI = MF.getFrameInfo ();
330
323
auto PtrVT = getPointerTy (MF.getDataLayout ());
331
324
332
- const Function *CalleeF = nullptr ;
333
- if (GlobalAddressSDNode *GAN = dyn_cast<GlobalAddressSDNode>(Callee)) {
334
- const GlobalValue *GV = GAN->getGlobal ();
335
- Callee = DAG.getTargetGlobalAddress (GV, dl, MVT::i32 );
336
- CalleeF = dyn_cast<Function>(GV);
337
- }
325
+ unsigned NumParams = CLI.CS .getInstruction ()
326
+ ? CLI.CS .getFunctionType ()->getNumParams ()
327
+ : 0 ;
328
+ if (GlobalAddressSDNode *GAN = dyn_cast<GlobalAddressSDNode>(Callee))
329
+ Callee = DAG.getTargetGlobalAddress (GAN->getGlobal (), dl, MVT::i32 );
338
330
339
331
// Analyze operands of the call, assigning locations to each operand.
340
332
SmallVector<CCValAssign, 16 > ArgLocs;
341
333
HexagonCCState CCInfo (CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext (),
342
- CalleeF );
334
+ NumParams );
343
335
344
336
if (Subtarget.useHVXOps ())
345
337
CCInfo.AnalyzeCallOperands (Outs, CC_Hexagon_HVX);
@@ -697,7 +689,7 @@ SDValue HexagonTargetLowering::LowerFormalArguments(
697
689
// Assign locations to all of the incoming arguments.
698
690
SmallVector<CCValAssign, 16 > ArgLocs;
699
691
HexagonCCState CCInfo (CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext (),
700
- & MF.getFunction ());
692
+ MF.getFunction (). getFunctionType ()-> getNumParams ());
701
693
702
694
if (Subtarget.useHVXOps ())
703
695
CCInfo.AnalyzeFormalArguments (Ins, CC_Hexagon_HVX);
0 commit comments