[cfe-commits] r62582 - /cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Eli Friedman eli.friedman at gmail.com
Tue Jan 20 09:25:25 PST 2009


Author: efriedma
Date: Tue Jan 20 11:25:25 2009
New Revision: 62582

URL: http://llvm.org/viewvc/llvm-project?rev=62582&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=62582&r1=62581&r2=62582&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Jan 20 11:25:25 2009
@@ -53,7 +53,12 @@
   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 @@
     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);





More information about the cfe-commits mailing list