diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-01-20 17:25:25 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-01-20 17:25:25 +0000 |
commit | c96c0511501190b631664ca556c0bf85537095d3 (patch) | |
tree | 176d00e394e13d96f9e71a104b490841939b3eb9 /lib/CodeGen/CGBuiltin.cpp | |
parent | 40f4e69002af9623a1f959bd57b99afda186a6a7 (diff) |
Do codegen correctly for va_start/end/copy on architectures where
va_list is a struct, like x86-64.
If anyone has a better idea for how to do the check in the if
statements, suggestions are welcome.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62582 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBuiltin.cpp')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 2d840ffd8d..043f284398 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -53,7 +53,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { case Builtin::BI__builtin_stdarg_start: case Builtin::BI__builtin_va_start: case Builtin::BI__builtin_va_end: { - Value *ArgValue = EmitLValue(E->getArg(0)).getAddress(); + Value *ArgValue; + if (CGM.getContext().getBuiltinVaListType()->isArrayType()) { + ArgValue = EmitScalarExpr(E->getArg(0)); + } else { + ArgValue = EmitLValue(E->getArg(0)).getAddress(); + } const llvm::Type *DestType = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); if (ArgValue->getType() != DestType) @@ -65,9 +70,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { 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 = EmitLValue(E->getArg(0)).getAddress(); - Value *SrcPtr = EmitLValue(E->getArg(1)).getAddress(); + Value *DstPtr, *SrcPtr; + if (CGM.getContext().getBuiltinVaListType()->isArrayType()) { + DstPtr = EmitScalarExpr(E->getArg(0)); + SrcPtr = EmitScalarExpr(E->getArg(1)); + } else { + DstPtr = EmitLValue(E->getArg(0)).getAddress(); + SrcPtr = EmitLValue(E->getArg(1)).getAddress(); + } const llvm::Type *Type = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); |