@@ -3038,8 +3038,30 @@ static Address EmitX86_64VAArgFromMemory(CodeGenFunction &CGF,
30383038 return Address (Res, LTy, Align);
30393039}
30403040
3041+ static RValue EmitMSABIVAArg (CodeGenFunction &CGF, Address VAListAddr,
3042+ QualType Ty, AggValueSlot Slot,
3043+ ASTContext &context) {
3044+ // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is
3045+ // not 1, 2, 4, or 8 bytes, must be passed by reference."
3046+ uint64_t Width = context.getTypeSize (Ty);
3047+ bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64 (Width);
3048+
3049+ return emitVoidPtrVAArg (CGF, VAListAddr, Ty, IsIndirect,
3050+ CGF.getContext ().getTypeInfoInChars (Ty),
3051+ CharUnits::fromQuantity (8 ),
3052+ /* allowHigherAlign*/ false , Slot);
3053+ }
3054+
30413055RValue X86_64ABIInfo::EmitVAArg (CodeGenFunction &CGF, Address VAListAddr,
30423056 QualType Ty, AggValueSlot Slot) const {
3057+
3058+ // Emit MS ABI compliant va_list for X86_64 targets which use Microsoft CXX
3059+ // ABI and CharPtrBuiltinVaList.
3060+ if (CGF.getTarget ().getCXXABI ().isMicrosoft () &&
3061+ CGF.getTarget ().getBuiltinVaListKind () ==
3062+ clang::TargetInfo::CharPtrBuiltinVaList)
3063+ return EmitMSABIVAArg (CGF, VAListAddr, Ty, Slot, getContext ());
3064+
30433065 // Assume that va_list type is correct; should be pointer to LLVM type:
30443066 // struct {
30453067 // i32 gp_offset;
@@ -3486,15 +3508,7 @@ void WinX86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
34863508
34873509RValue WinX86_64ABIInfo::EmitVAArg (CodeGenFunction &CGF, Address VAListAddr,
34883510 QualType Ty, AggValueSlot Slot) const {
3489- // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is
3490- // not 1, 2, 4, or 8 bytes, must be passed by reference."
3491- uint64_t Width = getContext ().getTypeSize (Ty);
3492- bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64 (Width);
3493-
3494- return emitVoidPtrVAArg (CGF, VAListAddr, Ty, IsIndirect,
3495- CGF.getContext ().getTypeInfoInChars (Ty),
3496- CharUnits::fromQuantity (8 ),
3497- /* allowHigherAlign*/ false , Slot);
3511+ return EmitMSABIVAArg (CGF, VAListAddr, Ty, Slot, getContext ());
34983512}
34993513
35003514std::unique_ptr<TargetCodeGenInfo> CodeGen::createX86_32TargetCodeGenInfo (
0 commit comments