[cfe-commits] r62585 - in /cfe/trunk/lib/CodeGen: CGBuiltin.cpp CGExprScalar.cpp CodeGenFunction.cpp CodeGenFunction.h
Eli Friedman
eli.friedman at gmail.com
Tue Jan 20 09:46:04 PST 2009
Author: efriedma
Date: Tue Jan 20 11:46:04 2009
New Revision: 62585
URL: http://llvm.org/viewvc/llvm-project?rev=62585&view=rev
Log:
Slight cleanup, and fix for va_arg on architectures where va_list is a
struct.
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=62585&r1=62584&r2=62585&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Jan 20 11:46:04 2009
@@ -53,12 +53,7 @@
case Builtin::BI__builtin_stdarg_start:
case Builtin::BI__builtin_va_start:
case Builtin::BI__builtin_va_end: {
- Value *ArgValue;
- if (CGM.getContext().getBuiltinVaListType()->isArrayType()) {
- ArgValue = EmitScalarExpr(E->getArg(0));
- } else {
- ArgValue = EmitLValue(E->getArg(0)).getAddress();
- }
+ Value *ArgValue = EmitVAListRef(E->getArg(0));;
const llvm::Type *DestType =
llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
if (ArgValue->getType() != DestType)
@@ -70,14 +65,8 @@
return RValue::get(Builder.CreateCall(CGM.getIntrinsic(inst), ArgValue));
}
case Builtin::BI__builtin_va_copy: {
- 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();
- }
+ Value *DstPtr = EmitVAListRef(E->getArg(0));
+ Value *SrcPtr = EmitVAListRef(E->getArg(1));
const llvm::Type *Type =
llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=62585&r1=62584&r2=62585&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Jan 20 11:46:04 2009
@@ -1286,7 +1286,7 @@
}
Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
- llvm::Value *ArgValue = EmitLValue(VE->getSubExpr()).getAddress();
+ llvm::Value *ArgValue = CGF.EmitVAListRef(VE->getSubExpr());
llvm::Value *ArgPtr = CGF.EmitVAArg(ArgValue, VE->getType());
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=62585&r1=62584&r2=62585&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Jan 20 11:46:04 2009
@@ -460,3 +460,10 @@
return 0;
}
+
+llvm::Value* CodeGenFunction::EmitVAListRef(const Expr* E) {
+ if (CGM.getContext().getBuiltinVaListType()->isArrayType()) {
+ return EmitScalarExpr(E);
+ }
+ return EmitLValue(E).getAddress();
+}
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=62585&r1=62584&r2=62585&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Jan 20 11:46:04 2009
@@ -314,6 +314,11 @@
RValue EmitAnyExpr(const Expr *E, llvm::Value *AggLoc = 0,
bool isAggLocVolatile = false);
+ // EmitVAListRef - Emit a "reference" to a va_list; this is either the
+ // address or the value of the expression, depending on how va_list is
+ // defined.
+ llvm::Value *EmitVAListRef(const Expr *E);
+
/// EmitAnyExprToTemp - Similary to EmitAnyExpr(), however, the result
/// will always be accessible even if no aggregate location is
/// provided.
More information about the cfe-commits
mailing list