aboutsummaryrefslogtreecommitdiff
path: root/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-02-09 20:26:43 +0000
committerAnders Carlsson <andersca@mac.com>2008-02-09 20:26:43 +0000
commita28ef8b5c6ea452472d89041128fac8b683fe968 (patch)
tree5923bbd41bde6e52b8e2d85f6f52bf007ff49754 /CodeGen
parent8bd36fcb4427519f41197d88b9121e2bbe9e3fc3 (diff)
Implement __builtin_va_copy
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46911 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen')
-rw-r--r--CodeGen/CGBuiltin.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/CodeGen/CGBuiltin.cpp b/CodeGen/CGBuiltin.cpp
index 661c09d7cd..83c5e60475 100644
--- a/CodeGen/CGBuiltin.cpp
+++ b/CodeGen/CGBuiltin.cpp
@@ -125,6 +125,25 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
Intrinsic::vastart : Intrinsic::vaend;
return RValue::get(Builder.CreateCall(CGM.getIntrinsic(inst), ArgValue));
}
+ case Builtin::BI__builtin_va_copy: {
+ // FIXME: This does not yet handle architectures where va_list is a struct.
+ Value *DstPtr = EmitScalarExpr(E->getArg(0));
+ Value *SrcValue = EmitScalarExpr(E->getArg(1));
+
+ Value *SrcPtr = CreateTempAlloca(SrcValue->getType(), "dst_ptr");
+
+ // FIXME: Volatile
+ Builder.CreateStore(SrcValue, SrcPtr, false);
+
+ const llvm::Type *Type =
+ llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+
+ DstPtr = Builder.CreateBitCast(DstPtr, Type);
+ SrcPtr = Builder.CreateBitCast(SrcPtr, Type);
+ Value *Args[] = { DstPtr, SrcPtr };
+ return RValue::get(Builder.CreateCall(CGM.getIntrinsic(Intrinsic::vacopy),
+ &Args[0], &Args[2]));
+ }
case Builtin::BI__builtin_classify_type: {
APSInt Result(32);
if (!E->isBuiltinClassifyType(Result))