From 8f2926b73ed635afecd020da787af6a837601a2b Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 23 Aug 2008 03:46:30 +0000 Subject: Trim CGObjCRuntime::GenerateMessageSend[Super] - Returns an RValue. - Reduced to only taking the CodeGenFunction, Expr, and Receiver. - Becomes responsible for emitting the arguments. Add CodeGenFunction::EmitCallExprExt - Takes optional extra arguments to insert at the head of the call. - This allows the Obj-C runtimes to call into this and isolates the argument and call instruction generation code to one place. Upshot is that we now pass structures (more) correctly. Also, fix one aspect of generating methods which take structure arguments (for NeXT). This probably needs to be merged with the SetFunctionAttributes code in CodeGenModule.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55223 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 4a80269230..c5b1f28618 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -776,7 +776,15 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType, // type. FnType = FnType->getAsPointerType()->getPointeeType(); QualType ResultType = FnType->getAsFunctionType()->getResultType(); + return EmitCallExprExt(Callee, ResultType, ArgBeg, ArgEnd, 0, 0); +} +RValue CodeGenFunction::EmitCallExprExt(llvm::Value *Callee, + QualType ResultType, + CallExpr::const_arg_iterator ArgBeg, + CallExpr::const_arg_iterator ArgEnd, + llvm::Value **ExtraArgs, + unsigned NumExtraArgs) { llvm::SmallVector Args; // Handle struct-return functions by passing a pointer to the location that @@ -787,6 +795,8 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType, // FIXME: set the stret attribute on the argument. } + Args.insert(Args.end(), ExtraArgs, ExtraArgs + NumExtraArgs); + for (CallExpr::const_arg_iterator I = ArgBeg; I != ArgEnd; ++I) { QualType ArgTy = I->getType(); @@ -812,7 +822,7 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType, if (hasAggregateLLVMType(ResultType)) ParamAttrList.push_back( llvm::ParamAttrsWithIndex::get(1, llvm::ParamAttr::StructRet)); - unsigned increment = hasAggregateLLVMType(ResultType) ? 2 : 1; + unsigned increment = NumExtraArgs + (hasAggregateLLVMType(ResultType) ? 2 : 1); unsigned i = 0; for (CallExpr::const_arg_iterator I = ArgBeg; I != ArgEnd; ++I, ++i) { -- cgit v1.2.3