|
@@ -278,7 +278,7 @@ void CodeGenFunction::FinishThunk() {
|
|
|
FinishFunction();
|
|
|
}
|
|
|
|
|
|
-void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Constant *CalleePtr,
|
|
|
+void CodeGenFunction::EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
|
|
|
const ThunkInfo *Thunk,
|
|
|
bool IsUnprototyped) {
|
|
|
assert(isa<CXXMethodDecl>(CurGD.getDecl()) &&
|
|
@@ -303,7 +303,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Constant *CalleePtr,
|
|
|
CGM.ErrorUnsupported(
|
|
|
MD, "non-trivial argument copy for return-adjusting thunk");
|
|
|
}
|
|
|
- EmitMustTailThunk(CurGD, AdjustedThisPtr, CalleePtr);
|
|
|
+ EmitMustTailThunk(CurGD, AdjustedThisPtr, Callee);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -354,8 +354,8 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Constant *CalleePtr,
|
|
|
|
|
|
// Now emit our call.
|
|
|
llvm::CallBase *CallOrInvoke;
|
|
|
- CGCallee Callee = CGCallee::forDirect(CalleePtr, CurGD);
|
|
|
- RValue RV = EmitCall(*CurFnInfo, Callee, Slot, CallArgs, &CallOrInvoke);
|
|
|
+ RValue RV = EmitCall(*CurFnInfo, CGCallee::forDirect(Callee, CurGD), Slot,
|
|
|
+ CallArgs, &CallOrInvoke);
|
|
|
|
|
|
// Consider return adjustment if we have ThunkInfo.
|
|
|
if (Thunk && !Thunk->Return.isEmpty())
|
|
@@ -375,7 +375,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Constant *CalleePtr,
|
|
|
|
|
|
void CodeGenFunction::EmitMustTailThunk(GlobalDecl GD,
|
|
|
llvm::Value *AdjustedThisPtr,
|
|
|
- llvm::Value *CalleePtr) {
|
|
|
+ llvm::FunctionCallee Callee) {
|
|
|
// Emitting a musttail call thunk doesn't use any of the CGCall.cpp machinery
|
|
|
// to translate AST arguments into LLVM IR arguments. For thunks, we know
|
|
|
// that the caller prototype more or less matches the callee prototype with
|
|
@@ -404,14 +404,14 @@ void CodeGenFunction::EmitMustTailThunk(GlobalDecl GD,
|
|
|
|
|
|
// Emit the musttail call manually. Even if the prologue pushed cleanups, we
|
|
|
// don't actually want to run them.
|
|
|
- llvm::CallInst *Call = Builder.CreateCall(CalleePtr, Args);
|
|
|
+ llvm::CallInst *Call = Builder.CreateCall(Callee, Args);
|
|
|
Call->setTailCallKind(llvm::CallInst::TCK_MustTail);
|
|
|
|
|
|
// Apply the standard set of call attributes.
|
|
|
unsigned CallingConv;
|
|
|
llvm::AttributeList Attrs;
|
|
|
- CGM.ConstructAttributeList(CalleePtr->getName(), *CurFnInfo, GD, Attrs,
|
|
|
- CallingConv, /*AttrOnCallSite=*/true);
|
|
|
+ CGM.ConstructAttributeList(Callee.getCallee()->getName(), *CurFnInfo, GD,
|
|
|
+ Attrs, CallingConv, /*AttrOnCallSite=*/true);
|
|
|
Call->setAttributes(Attrs);
|
|
|
Call->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
|
|
|
|
|
@@ -449,7 +449,8 @@ void CodeGenFunction::generateThunk(llvm::Function *Fn,
|
|
|
Callee = llvm::ConstantExpr::getBitCast(Callee, Fn->getType());
|
|
|
|
|
|
// Make the call and return the result.
|
|
|
- EmitCallAndReturnForThunk(Callee, &Thunk, IsUnprototyped);
|
|
|
+ EmitCallAndReturnForThunk(llvm::FunctionCallee(Fn->getFunctionType(), Callee),
|
|
|
+ &Thunk, IsUnprototyped);
|
|
|
}
|
|
|
|
|
|
static bool shouldEmitVTableThunk(CodeGenModule &CGM, const CXXMethodDecl *MD,
|