[llvm] 5dbf73f - [Lanai] Use ArgFlags to distinguish fixed parameters (#154278)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 02:38:05 PDT 2025


Author: Nikita Popov
Date: 2025-08-20T11:38:02+02:00
New Revision: 5dbf73f54dfc9d8f4262267937aa34a8421a54d6

URL: https://github.com/llvm/llvm-project/commit/5dbf73f54dfc9d8f4262267937aa34a8421a54d6
DIFF: https://github.com/llvm/llvm-project/commit/5dbf73f54dfc9d8f4262267937aa34a8421a54d6.diff

LOG: [Lanai] Use ArgFlags to distinguish fixed parameters (#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.

Added: 
    

Modified: 
    llvm/lib/Target/Lanai/LanaiISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Lanai/LanaiISelLowering.cpp b/llvm/lib/Target/Lanai/LanaiISelLowering.cpp
index 7a0a5103a23c9..f412f66d9d192 100644
--- a/llvm/lib/Target/Lanai/LanaiISelLowering.cpp
+++ b/llvm/lib/Target/Lanai/LanaiISelLowering.cpp
@@ -353,7 +353,6 @@ void LanaiTargetLowering::LowerAsmOperandForConstraint(
 
 #include "LanaiGenCallingConv.inc"
 
-static unsigned NumFixedArgs;
 static bool CC_Lanai32_VarArg(unsigned ValNo, MVT ValVT, MVT LocVT,
                               CCValAssign::LocInfo LocInfo,
                               ISD::ArgFlagsTy ArgFlags, Type *OrigTy,
@@ -361,9 +360,8 @@ static bool CC_Lanai32_VarArg(unsigned ValNo, MVT ValVT, MVT LocVT,
   // Handle fixed arguments with default CC.
   // Note: Both the default and fast CC handle VarArg the same and hence the
   // calling convention of the function is not considered here.
-  if (ValNo < NumFixedArgs) {
+  if (!ArgFlags.isVarArg())
     return CC_Lanai32(ValNo, ValVT, LocVT, LocInfo, ArgFlags, OrigTy, State);
-  }
 
   // Promote i8/i16 args to i32
   if (LocVT == MVT::i8 || LocVT == MVT::i16) {
@@ -604,15 +602,9 @@ SDValue LanaiTargetLowering::LowerCCCCallTo(
   GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee);
   MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo();
 
-  NumFixedArgs = 0;
-  if (IsVarArg && G) {
-    const Function *CalleeFn = dyn_cast<Function>(G->getGlobal());
-    if (CalleeFn)
-      NumFixedArgs = CalleeFn->getFunctionType()->getNumParams();
-  }
-  if (NumFixedArgs)
+  if (IsVarArg) {
     CCInfo.AnalyzeCallOperands(Outs, CC_Lanai32_VarArg);
-  else {
+  } else {
     if (CallConv == CallingConv::Fast)
       CCInfo.AnalyzeCallOperands(Outs, CC_Lanai32_Fast);
     else


        


More information about the llvm-commits mailing list