diff options
author | Guanzhong Chen <gzchen@google.com> | 2019-08-15 19:33:36 +0000 |
---|---|---|
committer | Guanzhong Chen <gzchen@google.com> | 2019-08-15 19:33:36 +0000 |
commit | 0cfda791b9567c46d47a80a0032ddbf7950e6d42 (patch) | |
tree | 6366c48ade8b81f36eefb58a4219f81e57d6e983 /lib/CodeGen | |
parent | d20aaf75882dd4c7320b000ac4444acba8e96f03 (diff) | |
download | clang-0cfda791b9567c46d47a80a0032ddbf7950e6d42.tar.gz |
[WebAssembly] Correctly handle va_arg of zero-sized structures
Summary:
D66168 passes size 0 structs indirectly, while the wasm backend expects it to
be passed directly. This causes subsequent variadic arguments to be read
incorrectly.
This diff changes it so that size 0 structs are passed directly.
Reviewers: dschuff, tlively, sbc100
Reviewed By: dschuff
Subscribers: jgravelle-google, aheejin, sunfish, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66255
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369042 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/TargetInfo.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index d96b5408f3..1124154447 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -833,8 +833,9 @@ ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const { Address WebAssemblyABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty) const { - bool IsIndirect = - isAggregateTypeForABI(Ty) && !isSingleElementStruct(Ty, getContext()); + bool IsIndirect = isAggregateTypeForABI(Ty) && + !isEmptyRecord(getContext(), Ty, true) && + !isSingleElementStruct(Ty, getContext()); return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, getContext().getTypeInfoInChars(Ty), CharUnits::fromQuantity(4), |