summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorGuanzhong Chen <gzchen@google.com>2019-08-13 21:41:11 +0000
committerGuanzhong Chen <gzchen@google.com>2019-08-13 21:41:11 +0000
commit8a503e439d0d254e5be5c2655a63a5a34b70dbac (patch)
treea1bc8ea03459b97817d1eb4d8ba67bcf87c215f4 /clang/lib/CodeGen
parent10f0668b572d49c1cda42f60d49a310cff2cd5a6 (diff)
downloadbcm5719-llvm-8a503e439d0d254e5be5c2655a63a5a34b70dbac.tar.gz
bcm5719-llvm-8a503e439d0d254e5be5c2655a63a5a34b70dbac.zip
[WebAssembly] Make clang emit correct va_arg code for structs
Summary: In the WebAssembly backend, when lowering variadic function calls, non-single member aggregate type arguments are always passed by pointer. However, when emitting va_arg code in clang, the arguments are instead read as if they are passed directly. This results in the pointer being read as the actual structure. Fixes https://github.com/emscripten-core/emscripten/issues/9042. Reviewers: tlively, sbc100, kripken, aheejin, dschuff Reviewed By: dschuff Subscribers: dschuff, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66168 llvm-svn: 368750
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 884b80cecd0..d96b5408f31 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -833,10 +833,12 @@ ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const {
Address WebAssemblyABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
QualType Ty) const {
- return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*IsIndirect=*/ false,
+ bool IsIndirect =
+ isAggregateTypeForABI(Ty) && !isSingleElementStruct(Ty, getContext());
+ return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
getContext().getTypeInfoInChars(Ty),
CharUnits::fromQuantity(4),
- /*AllowHigherAlign=*/ true);
+ /*AllowHigherAlign=*/true);
}
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud