Implement lowering of va_arg in clang directly. (This is 32-bit X86 only for now).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58681 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 28fb9a3..e8ab1bb 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -256,10 +256,14 @@
void AggExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
llvm::Value *ArgValue = CGF.EmitLValue(VE->getSubExpr()).getAddress();
- llvm::Value *V = Builder.CreateVAArg(ArgValue, CGF.ConvertType(VE->getType()));
+ llvm::Value *ArgPtr = CGF.EmitVAArg(ArgValue, VE->getType());
+
+ if (!ArgPtr)
+ CGF.ErrorUnsupported(VE, "aggregate va_arg expression");
+
if (DestPtr)
// FIXME: volatility
- Builder.CreateStore(V, DestPtr);
+ CGF.EmitAggregateCopy(DestPtr, ArgPtr, VE->getType());
}
void AggExprEmitter::EmitNonConstInit(InitListExpr *E) {