diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -4358,15 +4358,10 @@ Address WinX86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty) const { - - bool IsIndirect = false; - // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is // not 1, 2, 4, or 8 bytes, must be passed by reference." - if (isAggregateTypeForABI(Ty) || Ty->isMemberPointerType()) { - uint64_t Width = getContext().getTypeSize(Ty); - IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width); - } + uint64_t Width = getContext().getTypeSize(Ty); + bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width); return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, CGF.getContext().getTypeInfoInChars(Ty), diff --git a/clang/test/CodeGen/mingw-long-double.c b/clang/test/CodeGen/mingw-long-double.c --- a/clang/test/CodeGen/mingw-long-double.c +++ b/clang/test/CodeGen/mingw-long-double.c @@ -45,3 +45,16 @@ // GNU32: declare dso_local void @__mulxc3 // GNU64: declare dso_local void @__mulxc3 // MSC64: declare dso_local void @__muldc3 + +void VarArgLD(int a, ...) { + // GNU32-LABEL: define{{.*}} void @VarArgLD + // GNU64-LABEL: define{{.*}} void @VarArgLD + // MSC64-LABEL: define{{.*}} void @VarArgLD + __builtin_va_list ap; + __builtin_va_start(ap, a); + long double LD = __builtin_va_arg(ap, long double); + // GNU32: bitcast i8* %argp.cur to x86_fp80* + // GNU64: bitcast i8* %argp.cur to x86_fp80** + // MSC64: bitcast i8* %argp.cur to double* + __builtin_va_end(ap); +} diff --git a/clang/test/CodeGen/win64-i128.c b/clang/test/CodeGen/win64-i128.c --- a/clang/test/CodeGen/win64-i128.c +++ b/clang/test/CodeGen/win64-i128.c @@ -14,3 +14,14 @@ // GNU64: define dso_local <2 x i64> @bar(i128* %0, i128* %1) // MSC64: define dso_local <2 x i64> @bar(i128* %0, i128* %1) + +void vararg(int a, ...) { + // GNU64-LABEL: define{{.*}} void @vararg + // MSC64-LABEL: define{{.*}} void @vararg + __builtin_va_list ap; + __builtin_va_start(ap, a); + int128_t i = __builtin_va_arg(ap, int128_t); + // GNU64: bitcast i8* %argp.cur to i128** + // MSC64: bitcast i8* %argp.cur to i128** + __builtin_va_end(ap); +}