[PATCH] MS ABI: Use musttail for vtable thunks that pass arguments by value
David Majnemer
david.majnemer at gmail.com
Fri Jul 25 18:19:40 PDT 2014
LGTM with comments addressed.
================
Comment at: lib/CodeGen/CGVTables.cpp:260-261
@@ -248,5 +259,4 @@
// Add the rest of the arguments.
- for (FunctionDecl::param_const_iterator I = MD->param_begin(),
- E = MD->param_end(); I != E; ++I)
- EmitDelegateCallArg(CallArgs, *I, (*I)->getLocStart());
+ for (const ParmVarDecl *PD : MD->params())
+ EmitDelegateCallArg(CallArgs, PD, PD->getLocStart());
----------------
Commit this separately.
================
Comment at: lib/CodeGen/CGVTables.cpp:317-319
@@ +316,5 @@
+ // the exception of 'this'.
+ SmallVector<llvm::Value *, 8> Args;
+ for (llvm::Argument &A : CurFn->args())
+ Args.push_back(&A);
+
----------------
`SmallVector<llvm::Value *, 8> Args(CurFn->arg_begin(), CurFn->arg_end());` would be more efficient, it will reserve the "right" amount up-front.
================
Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1470
@@ -1469,27 +1469,3 @@
- unsigned CallingConv;
- CodeGen::AttributeListType AttributeList;
- CGM.ConstructAttributeList(FnInfo, MD, AttributeList, CallingConv, true);
- llvm::AttributeSet Attrs =
- llvm::AttributeSet::get(CGF.getLLVMContext(), AttributeList);
-
- // Do a musttail call with perfect argument forwarding. Any inalloca argument
- // will be forwarded in place without any copy.
- SmallVector<llvm::Value *, 8> Args;
- for (llvm::Argument &A : ThunkFn->args())
- Args.push_back(&A);
- llvm::CallInst *Call = CGF.Builder.CreateCall(Callee, Args);
- Call->setTailCallKind(llvm::CallInst::TCK_MustTail);
- Call->setAttributes(Attrs);
- Call->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
-
- if (Call->getType()->isVoidTy())
- CGF.Builder.CreateRetVoid();
- else
- CGF.Builder.CreateRet(Call);
-
- // Finish the function to maintain CodeGenFunction invariants.
- // FIXME: Don't emit unreachable code.
- CGF.EmitBlock(CGF.createBasicBlock());
- CGF.FinishFunction();
+ CGF.EmitCallAndReturnForThunk(Callee, 0);
----------------
`CGF.EmitCallAndReturnForThunk(Callee, /*Thunk=*/nullptr);`
http://reviews.llvm.org/D4613
More information about the cfe-commits
mailing list