Pass the return value slot to all call exprs.

llvm-svn: 92145
This commit is contained in:
Anders Carlsson 2009-12-24 21:13:40 +00:00
parent 1f21000902
commit bfb3671b25
5 changed files with 29 additions and 20 deletions

View File

@ -460,7 +460,8 @@ const llvm::Type *BlockModule::getGenericExtendedBlockLiteralType() {
return GenericExtendedBlockLiteralType; return GenericExtendedBlockLiteralType;
} }
RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) { RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E,
ReturnValueSlot ReturnValue) {
const BlockPointerType *BPT = const BlockPointerType *BPT =
E->getCallee()->getType()->getAs<BlockPointerType>(); E->getCallee()->getType()->getAs<BlockPointerType>();
@ -509,7 +510,7 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
Func = Builder.CreateBitCast(Func, BlockFTyPtr); Func = Builder.CreateBitCast(Func, BlockFTyPtr);
// And call the block. // And call the block.
return EmitCall(FnInfo, Func, ReturnValueSlot(), Args); return EmitCall(FnInfo, Func, ReturnValue, Args);
} }
uint64_t CodeGenFunction::AllocateBlockDecl(const BlockDeclRefExpr *E) { uint64_t CodeGenFunction::AllocateBlockDecl(const BlockDeclRefExpr *E) {

View File

@ -28,6 +28,7 @@ using namespace CodeGen;
RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD, RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD,
llvm::Value *Callee, llvm::Value *Callee,
ReturnValueSlot ReturnValue,
llvm::Value *This, llvm::Value *This,
CallExpr::const_arg_iterator ArgBeg, CallExpr::const_arg_iterator ArgBeg,
CallExpr::const_arg_iterator ArgEnd) { CallExpr::const_arg_iterator ArgEnd) {
@ -47,7 +48,7 @@ RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD,
QualType ResultType = MD->getType()->getAs<FunctionType>()->getResultType(); QualType ResultType = MD->getType()->getAs<FunctionType>()->getResultType();
return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args), Callee, return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args), Callee,
ReturnValueSlot(), Args, MD); ReturnValue, Args, MD);
} }
/// canDevirtualizeMemberFunctionCalls - Checks whether virtual calls on given /// canDevirtualizeMemberFunctionCalls - Checks whether virtual calls on given
@ -78,9 +79,10 @@ static bool canDevirtualizeMemberFunctionCalls(const Expr *Base) {
return false; return false;
} }
RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) { RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE,
ReturnValueSlot ReturnValue) {
if (isa<BinaryOperator>(CE->getCallee()->IgnoreParens())) if (isa<BinaryOperator>(CE->getCallee()->IgnoreParens()))
return EmitCXXMemberPointerCallExpr(CE); return EmitCXXMemberPointerCallExpr(CE, ReturnValue);
const MemberExpr *ME = cast<MemberExpr>(CE->getCallee()->IgnoreParens()); const MemberExpr *ME = cast<MemberExpr>(CE->getCallee()->IgnoreParens());
const CXXMethodDecl *MD = cast<CXXMethodDecl>(ME->getMemberDecl()); const CXXMethodDecl *MD = cast<CXXMethodDecl>(ME->getMemberDecl());
@ -89,7 +91,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
// The method is static, emit it as we would a regular call. // The method is static, emit it as we would a regular call.
llvm::Value *Callee = CGM.GetAddrOfFunction(MD); llvm::Value *Callee = CGM.GetAddrOfFunction(MD);
return EmitCall(getContext().getPointerType(MD->getType()), Callee, 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<FunctionProtoType>(); const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
@ -138,12 +140,13 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
Callee = CGM.GetAddrOfFunction(MD, Ty); Callee = CGM.GetAddrOfFunction(MD, Ty);
} }
return EmitCXXMemberCall(MD, Callee, This, return EmitCXXMemberCall(MD, Callee, ReturnValue, This,
CE->arg_begin(), CE->arg_end()); CE->arg_begin(), CE->arg_end());
} }
RValue RValue
CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E) { CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
ReturnValueSlot ReturnValue) {
const BinaryOperator *BO = const BinaryOperator *BO =
cast<BinaryOperator>(E->getCallee()->IgnoreParens()); cast<BinaryOperator>(E->getCallee()->IgnoreParens());
const Expr *BaseExpr = BO->getLHS(); const Expr *BaseExpr = BO->getLHS();
@ -247,12 +250,13 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E) {
EmitCallArgs(Args, FPT, E->arg_begin(), E->arg_end()); EmitCallArgs(Args, FPT, E->arg_begin(), E->arg_end());
QualType ResultType = BO->getType()->getAs<FunctionType>()->getResultType(); QualType ResultType = BO->getType()->getAs<FunctionType>()->getResultType();
return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args), Callee, return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args), Callee,
ReturnValueSlot(), Args); ReturnValue, Args);
} }
RValue RValue
CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
const CXXMethodDecl *MD) { const CXXMethodDecl *MD,
ReturnValueSlot ReturnValue) {
assert(MD->isInstance() && assert(MD->isInstance() &&
"Trying to emit a member call expr on a static method!"); "Trying to emit a member call expr on a static method!");
@ -282,7 +286,7 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
else else
Callee = CGM.GetAddrOfFunction(MD, Ty); Callee = CGM.GetAddrOfFunction(MD, Ty);
return EmitCXXMemberCall(MD, Callee, This, return EmitCXXMemberCall(MD, Callee, ReturnValue, This,
E->arg_begin() + 1, E->arg_end()); E->arg_begin() + 1, E->arg_end());
} }
@ -526,7 +530,7 @@ CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
llvm::Value *Callee = CGM.GetAddrOfCXXConstructor(D, Type); 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, void CodeGenFunction::EmitCXXDestructorCall(const CXXDestructorDecl *DD,

View File

@ -1522,10 +1522,10 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E,
ReturnValueSlot ReturnValue) { ReturnValueSlot ReturnValue) {
// Builtins never have block type. // Builtins never have block type.
if (E->getCallee()->getType()->isBlockPointerType()) if (E->getCallee()->getType()->isBlockPointerType())
return EmitBlockCallExpr(E); return EmitBlockCallExpr(E, ReturnValue);
if (const CXXMemberCallExpr *CE = dyn_cast<CXXMemberCallExpr>(E)) if (const CXXMemberCallExpr *CE = dyn_cast<CXXMemberCallExpr>(E))
return EmitCXXMemberCallExpr(CE); return EmitCXXMemberCallExpr(CE, ReturnValue);
const Decl *TargetDecl = 0; const Decl *TargetDecl = 0;
if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E->getCallee())) { if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E->getCallee())) {
@ -1539,7 +1539,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E,
if (const CXXOperatorCallExpr *CE = dyn_cast<CXXOperatorCallExpr>(E)) if (const CXXOperatorCallExpr *CE = dyn_cast<CXXOperatorCallExpr>(E))
if (const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(TargetDecl)) if (const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(TargetDecl))
return EmitCXXOperatorMemberCallExpr(CE, MD); return EmitCXXOperatorMemberCallExpr(CE, MD, ReturnValue);
if (isa<CXXPseudoDestructorExpr>(E->getCallee()->IgnoreParens())) { if (isa<CXXPseudoDestructorExpr>(E->getCallee()->IgnoreParens())) {
// C++ [expr.pseudo]p1: // C++ [expr.pseudo]p1:

View File

@ -406,7 +406,7 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
/*isVariadic=*/false); /*isVariadic=*/false);
llvm::Value *Callee = BuildVirtualCall(Dtor, Dtor_Deleting, Ptr, Ty); 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. // The dtor took care of deleting the object.
ShouldCallDelete = false; ShouldCallDelete = false;

View File

@ -1055,20 +1055,24 @@ public:
RValue EmitCXXMemberCall(const CXXMethodDecl *MD, RValue EmitCXXMemberCall(const CXXMethodDecl *MD,
llvm::Value *Callee, llvm::Value *Callee,
ReturnValueSlot ReturnValue,
llvm::Value *This, llvm::Value *This,
CallExpr::const_arg_iterator ArgBeg, CallExpr::const_arg_iterator ArgBeg,
CallExpr::const_arg_iterator ArgEnd); CallExpr::const_arg_iterator ArgEnd);
RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E); RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E,
RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E); ReturnValueSlot ReturnValue);
RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
ReturnValueSlot ReturnValue);
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
const CXXMethodDecl *MD); const CXXMethodDecl *MD,
ReturnValueSlot ReturnValue);
RValue EmitBuiltinExpr(const FunctionDecl *FD, RValue EmitBuiltinExpr(const FunctionDecl *FD,
unsigned BuiltinID, const CallExpr *E); 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 /// EmitTargetBuiltinExpr - Emit the given builtin call. Returns 0 if the call
/// is unhandled by the current target. /// is unhandled by the current target.