[llvm] [AArch64][SVE] Remove isSVECC() in favour of changing the calling convention (PR #152742)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 8 09:46:03 PDT 2025
================
@@ -7837,24 +7838,44 @@ SDValue AArch64TargetLowering::LowerFormalArguments(
const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &DL,
SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const {
MachineFunction &MF = DAG.getMachineFunction();
- const Function &F = MF.getFunction();
+ Function &F = MF.getFunction();
MachineFrameInfo &MFI = MF.getFrameInfo();
bool IsWin64 =
Subtarget->isCallingConvWin64(F.getCallingConv(), F.isVarArg());
bool StackViaX4 = CallConv == CallingConv::ARM64EC_Thunk_X64 ||
(isVarArg && Subtarget->isWindowsArm64EC());
AArch64FunctionInfo *FuncInfo = MF.getInfo<AArch64FunctionInfo>();
- SmallVector<ISD::OutputArg, 4> Outs;
- GetReturnInfo(CallConv, F.getReturnType(), F.getAttributes(), Outs,
- DAG.getTargetLoweringInfo(), MF.getDataLayout());
- if (any_of(Outs, [](ISD::OutputArg &Out){ return Out.VT.isScalableVector(); }))
- FuncInfo->setIsSVECC(true);
-
// Assign locations to all of the incoming arguments.
SmallVector<CCValAssign, 16> ArgLocs;
CCState CCInfo(CallConv, isVarArg, MF, ArgLocs, *DAG.getContext());
+ // This logic is consistent with AArch64TargetLowering::LowerCall.
+ // The `ShouldUpgradeToSVECC` flag can be when analyzing arguments.
+ bool ShouldUpgradeToSVECC = false;
+ auto _ = make_scope_exit([&] {
+ if (CallConv != CallingConv::C && CallConv != CallingConv::Fast)
+ return;
+
+ if (!ShouldUpgradeToSVECC) {
+ // If the flag was not set, check if the return value requires the SVE CC.
+ SmallVector<ISD::OutputArg, 4> Outs;
+ GetReturnInfo(CallConv, F.getReturnType(), F.getAttributes(), Outs,
+ DAG.getTargetLoweringInfo(), MF.getDataLayout());
+ ShouldUpgradeToSVECC = any_of(
+ Outs, [](ISD::OutputArg &Out) { return Out.VT.isScalableVector(); });
+ }
+
+ if (!ShouldUpgradeToSVECC)
+ return;
+
+ if (isVarArg)
+ report_fatal_error("Passing/returning SVE types to variadic functions "
+ "is currently not supported");
----------------
sdesmalen-arm wrote:
You can pass them to variadic functions, but not as variadic arguments.
https://github.com/llvm/llvm-project/pull/152742
More information about the llvm-commits
mailing list