Skip to content

Commit 5dbf73f

Browse files
authored
[Lanai] Use ArgFlags to distinguish fixed parameters (llvm#154278)
Whether the argument is fixed is now available via ArgFlags, so make use of it. The previous implementation was quite problematic, because it stored the number of fixed arguments in a global variable, which is not thread safe.
1 parent 9df7ca1 commit 5dbf73f

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

llvm/lib/Target/Lanai/LanaiISelLowering.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,15 @@ void LanaiTargetLowering::LowerAsmOperandForConstraint(
353353

354354
#include "LanaiGenCallingConv.inc"
355355

356-
static unsigned NumFixedArgs;
357356
static bool CC_Lanai32_VarArg(unsigned ValNo, MVT ValVT, MVT LocVT,
358357
CCValAssign::LocInfo LocInfo,
359358
ISD::ArgFlagsTy ArgFlags, Type *OrigTy,
360359
CCState &State) {
361360
// Handle fixed arguments with default CC.
362361
// Note: Both the default and fast CC handle VarArg the same and hence the
363362
// calling convention of the function is not considered here.
364-
if (ValNo < NumFixedArgs) {
363+
if (!ArgFlags.isVarArg())
365364
return CC_Lanai32(ValNo, ValVT, LocVT, LocInfo, ArgFlags, OrigTy, State);
366-
}
367365

368366
// Promote i8/i16 args to i32
369367
if (LocVT == MVT::i8 || LocVT == MVT::i16) {
@@ -604,15 +602,9 @@ SDValue LanaiTargetLowering::LowerCCCCallTo(
604602
GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee);
605603
MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo();
606604

607-
NumFixedArgs = 0;
608-
if (IsVarArg && G) {
609-
const Function *CalleeFn = dyn_cast<Function>(G->getGlobal());
610-
if (CalleeFn)
611-
NumFixedArgs = CalleeFn->getFunctionType()->getNumParams();
612-
}
613-
if (NumFixedArgs)
605+
if (IsVarArg) {
614606
CCInfo.AnalyzeCallOperands(Outs, CC_Lanai32_VarArg);
615-
else {
607+
} else {
616608
if (CallConv == CallingConv::Fast)
617609
CCInfo.AnalyzeCallOperands(Outs, CC_Lanai32_Fast);
618610
else

0 commit comments

Comments
 (0)