From a1736c0c750d4514a5d8fda36670addf1e4de54a Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Thu, 24 Dec 2009 21:13:40 +0000 Subject: [PATCH] Pass the return value slot to all call exprs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92145 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGBlocks.cpp | 5 +++-- lib/CodeGen/CGCXX.cpp | 24 ++++++++++++++---------- lib/CodeGen/CGExpr.cpp | 6 +++--- lib/CodeGen/CGExprCXX.cpp | 2 +- lib/CodeGen/CodeGenFunction.h | 12 ++++++++---- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 2270f84b5b..1bece7fec6 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -460,7 +460,8 @@ const llvm::Type *BlockModule::getGenericExtendedBlockLiteralType() { return GenericExtendedBlockLiteralType; } -RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) { +RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E, + ReturnValueSlot ReturnValue) { const BlockPointerType *BPT = E->getCallee()->getType()->getAs(); @@ -509,7 +510,7 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) { Func = Builder.CreateBitCast(Func, BlockFTyPtr); // And call the block. - return EmitCall(FnInfo, Func, ReturnValueSlot(), Args); + return EmitCall(FnInfo, Func, ReturnValue, Args); } uint64_t CodeGenFunction::AllocateBlockDecl(const BlockDeclRefExpr *E) { diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index ba83087ebc..179ee70381 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -28,6 +28,7 @@ using namespace CodeGen; RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD, llvm::Value *Callee, + ReturnValueSlot ReturnValue, llvm::Value *This, CallExpr::const_arg_iterator ArgBeg, CallExpr::const_arg_iterator ArgEnd) { @@ -47,7 +48,7 @@ RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD, QualType ResultType = MD->getType()->getAs()->getResultType(); return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args), Callee, - ReturnValueSlot(), Args, MD); + ReturnValue, Args, MD); } /// canDevirtualizeMemberFunctionCalls - Checks whether virtual calls on given @@ -78,9 +79,10 @@ static bool canDevirtualizeMemberFunctionCalls(const Expr *Base) { return false; } -RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) { +RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, + ReturnValueSlot ReturnValue) { if (isa(CE->getCallee()->IgnoreParens())) - return EmitCXXMemberPointerCallExpr(CE); + return EmitCXXMemberPointerCallExpr(CE, ReturnValue); const MemberExpr *ME = cast(CE->getCallee()->IgnoreParens()); const CXXMethodDecl *MD = cast(ME->getMemberDecl()); @@ -89,7 +91,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) { // The method is static, emit it as we would a regular call. llvm::Value *Callee = CGM.GetAddrOfFunction(MD); return EmitCall(getContext().getPointerType(MD->getType()), Callee, - ReturnValueSlot(), CE->arg_begin(), CE->arg_end()); + ReturnValue, CE->arg_begin(), CE->arg_end()); } const FunctionProtoType *FPT = MD->getType()->getAs(); @@ -138,12 +140,13 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) { Callee = CGM.GetAddrOfFunction(MD, Ty); } - return EmitCXXMemberCall(MD, Callee, This, + return EmitCXXMemberCall(MD, Callee, ReturnValue, This, CE->arg_begin(), CE->arg_end()); } RValue -CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E) { +CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, + ReturnValueSlot ReturnValue) { const BinaryOperator *BO = cast(E->getCallee()->IgnoreParens()); const Expr *BaseExpr = BO->getLHS(); @@ -247,12 +250,13 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E) { EmitCallArgs(Args, FPT, E->arg_begin(), E->arg_end()); QualType ResultType = BO->getType()->getAs()->getResultType(); return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args), Callee, - ReturnValueSlot(), Args); + ReturnValue, Args); } RValue CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, - const CXXMethodDecl *MD) { + const CXXMethodDecl *MD, + ReturnValueSlot ReturnValue) { assert(MD->isInstance() && "Trying to emit a member call expr on a static method!"); @@ -282,7 +286,7 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, else Callee = CGM.GetAddrOfFunction(MD, Ty); - return EmitCXXMemberCall(MD, Callee, This, + return EmitCXXMemberCall(MD, Callee, ReturnValue, This, E->arg_begin() + 1, E->arg_end()); } @@ -526,7 +530,7 @@ CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D, llvm::Value *Callee = CGM.GetAddrOfCXXConstructor(D, Type); - EmitCXXMemberCall(D, Callee, This, ArgBeg, ArgEnd); + EmitCXXMemberCall(D, Callee, ReturnValueSlot(), This, ArgBeg, ArgEnd); } void CodeGenFunction::EmitCXXDestructorCall(const CXXDestructorDecl *DD, diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 059b3827e6..fbeb40cefc 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1522,10 +1522,10 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue) { // Builtins never have block type. if (E->getCallee()->getType()->isBlockPointerType()) - return EmitBlockCallExpr(E); + return EmitBlockCallExpr(E, ReturnValue); if (const CXXMemberCallExpr *CE = dyn_cast(E)) - return EmitCXXMemberCallExpr(CE); + return EmitCXXMemberCallExpr(CE, ReturnValue); const Decl *TargetDecl = 0; if (const ImplicitCastExpr *CE = dyn_cast(E->getCallee())) { @@ -1539,7 +1539,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, if (const CXXOperatorCallExpr *CE = dyn_cast(E)) if (const CXXMethodDecl *MD = dyn_cast_or_null(TargetDecl)) - return EmitCXXOperatorMemberCallExpr(CE, MD); + return EmitCXXOperatorMemberCallExpr(CE, MD, ReturnValue); if (isa(E->getCallee()->IgnoreParens())) { // C++ [expr.pseudo]p1: diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index f16c7a2f45..0f6a83041a 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -406,7 +406,7 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { /*isVariadic=*/false); llvm::Value *Callee = BuildVirtualCall(Dtor, Dtor_Deleting, Ptr, Ty); - EmitCXXMemberCall(Dtor, Callee, Ptr, 0, 0); + EmitCXXMemberCall(Dtor, Callee, ReturnValueSlot(), Ptr, 0, 0); // The dtor took care of deleting the object. ShouldCallDelete = false; diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 487a797b72..273ddcac79 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -1055,20 +1055,24 @@ public: RValue EmitCXXMemberCall(const CXXMethodDecl *MD, llvm::Value *Callee, + ReturnValueSlot ReturnValue, llvm::Value *This, CallExpr::const_arg_iterator ArgBeg, CallExpr::const_arg_iterator ArgEnd); - RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E); - RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E); + RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E, + ReturnValueSlot ReturnValue); + RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, + ReturnValueSlot ReturnValue); RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, - const CXXMethodDecl *MD); + const CXXMethodDecl *MD, + ReturnValueSlot ReturnValue); RValue EmitBuiltinExpr(const FunctionDecl *FD, unsigned BuiltinID, const CallExpr *E); - RValue EmitBlockCallExpr(const CallExpr *E); + RValue EmitBlockCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue); /// EmitTargetBuiltinExpr - Emit the given builtin call. Returns 0 if the call /// is unhandled by the current target. -- 2.40.0