Index: lib/CodeGen/TargetInfo.cpp =================================================================== --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -4770,10 +4770,11 @@ private: ABIKind Kind; + bool IsMS; public: - AArch64ABIInfo(CodeGenTypes &CGT, ABIKind Kind) - : SwiftABIInfo(CGT), Kind(Kind) {} + AArch64ABIInfo(CodeGenTypes &CGT, ABIKind Kind, bool MS) + : SwiftABIInfo(CGT), Kind(Kind), IsMS(MS) {} private: ABIKind getABIKind() const { return Kind; } @@ -4803,9 +4804,12 @@ Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty) const override { - return isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF) - : EmitAAPCSVAArg(VAListAddr, Ty, CGF); + return IsMS ? EmitMSVAArg(CGF, VAListAddr, Ty) + : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF) + : EmitAAPCSVAArg(VAListAddr, Ty, CGF); } + Address EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr, + QualType Ty) const override; bool shouldPassIndirectlyForSwift(CharUnits totalSize, ArrayRef scalars, @@ -4822,8 +4826,9 @@ class AArch64TargetCodeGenInfo : public TargetCodeGenInfo { public: - AArch64TargetCodeGenInfo(CodeGenTypes &CGT, AArch64ABIInfo::ABIKind Kind) - : TargetCodeGenInfo(new AArch64ABIInfo(CGT, Kind)) {} + AArch64TargetCodeGenInfo(CodeGenTypes &CGT, AArch64ABIInfo::ABIKind Kind, + bool IsMS) + : TargetCodeGenInfo(new AArch64ABIInfo(CGT, Kind, IsMS)) {} StringRef getARCRetainAutoreleasedReturnValueMarker() const override { return "mov\tfp, fp\t\t# marker for objc_retainAutoreleaseReturnValue"; @@ -5312,6 +5317,14 @@ TyInfo, SlotSize, /*AllowHigherAlign*/ true); } +Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr, + QualType Ty) const { + return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false, + CGF.getContext().getTypeInfoInChars(Ty), + CharUnits::fromQuantity(8), + /*allowHigherAlign*/ false); +} + //===----------------------------------------------------------------------===// // ARM ABI Implementation //===----------------------------------------------------------------------===// @@ -8448,7 +8461,8 @@ if (getTarget().getABI() == "darwinpcs") Kind = AArch64ABIInfo::DarwinPCS; - return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind)); + return SetCGInfo(new AArch64TargetCodeGenInfo( + Types, Kind, Triple.getOS() == llvm::Triple::Win32)); } case llvm::Triple::wasm32: