@@ -474,8 +474,11 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
474474 Ty, IsNamedArg, NVec, NPred, UnpaddedCoerceToSeq, NSRN, NPRN);
475475 }
476476
477- // Aggregates <= 16 bytes are passed directly in registers or on the stack.
478- if (Size <= 128 ) {
477+ // Aggregates <= 16 bytes (8 bytes for variadic Arm64EC) are passed directly
478+ // in registers or on the stack.
479+ uint64_t MaxDirectSize =
480+ (IsVariadicFn && getTarget ().getTriple ().isWindowsArm64EC ()) ? 64 : 128 ;
481+ if (Size <= MaxDirectSize) {
479482 unsigned Alignment;
480483 if (Kind == AArch64ABIKind::AAPCS) {
481484 Alignment = getContext ().getTypeUnadjustedAlign (Ty);
@@ -1152,8 +1155,11 @@ RValue AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
11521155 QualType Ty, AggValueSlot Slot) const {
11531156 bool IsIndirect = false ;
11541157
1155- // Composites larger than 16 bytes are passed by reference.
1156- if (isAggregateTypeForABI (Ty) && getContext ().getTypeSize (Ty) > 128 )
1158+ // Composites larger than 16 bytes (8 bytes on Arm64EC) are passed by
1159+ // reference.
1160+ uint64_t MaxDirectSize =
1161+ getTarget ().getTriple ().isWindowsArm64EC () ? 64 : 128 ;
1162+ if (isAggregateTypeForABI (Ty) && getContext ().getTypeSize (Ty) > MaxDirectSize)
11571163 IsIndirect = true ;
11581164
11591165 return emitVoidPtrVAArg (CGF, VAListAddr, Ty, IsIndirect,
0 commit comments