summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-08-25 20:42:26 +0000
committerReid Kleckner <rnk@google.com>2016-08-25 20:42:26 +0000
commitb04449d97a15cb47b56492899e3182db8d8cb30c (patch)
treef7ab61878b68aee7ad0dff32a5ad8d4b52bb7443 /clang/lib
parent3495647d0dc63a5a657794134afa19a8fc80cb1b (diff)
downloadbcm5719-llvm-b04449d97a15cb47b56492899e3182db8d8cb30c.tar.gz
bcm5719-llvm-b04449d97a15cb47b56492899e3182db8d8cb30c.zip
[MS] Win64 va_arg should expect large arguments to be passed indirectly
Fixes PR20569 llvm-svn: 279774
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 759e3d6f406..9fd7c493e03 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -3651,7 +3651,17 @@ void WinX86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
Address WinX86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
QualType Ty) const {
- return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+
+ 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);
+ }
+
+ return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
CGF.getContext().getTypeInfoInChars(Ty),
CharUnits::fromQuantity(8),
/*allowHigherAlign*/ false);
OpenPOWER on IntegriCloud