[llvm] [Lanai] Use ArgFlags to distinguish fixed parameters (PR #154278)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 00:39:47 PDT 2025
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/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.
>From ad7abbbc64755791e79e940e4679657bdcf05718 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Tue, 19 Aug 2025 09:36:53 +0200
Subject: [PATCH] [Lanai] Use ArgFlags to distinguish fixed parameters
Whether the argument is fixed is now available via ArgFlags, so
make use of it. The previous implementation was very broken,
because it stored the number of fixed arguments in a global
variable, which is not thread safe.
---
llvm/lib/Target/Lanai/LanaiISelLowering.cpp | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
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