CodeGen: Have 'this'-returning constructors and destructors to take advantage of the new backend 'returned' attribute.
The backend will now use the generic 'returned' attribute to form tail calls where possible, as well as avoid save-restores of 'this' in some cases (specifically the cases that matter for the ARM C++ ABI). This patch also reverts a prior front-end only partial implementation of these optimizations, since it's no longer required. llvm-svn: 184205
This commit is contained in:
@@ -717,6 +717,14 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD,
|
||||
if (!IsIncompleteFunction)
|
||||
SetLLVMFunctionAttributes(FD, getTypes().arrangeGlobalDeclaration(GD), F);
|
||||
|
||||
if (getCXXABI().HasThisReturn(GD)) {
|
||||
llvm::Type *RetTy = F->getReturnType();
|
||||
assert(!F->arg_empty() &&
|
||||
F->arg_begin()->getType()->canLosslesslyBitCastTo(RetTy) &&
|
||||
"unexpected this return");
|
||||
F->addAttribute(1, llvm::Attribute::Returned);
|
||||
}
|
||||
|
||||
// Only a few attributes are set on declarations; these may later be
|
||||
// overridden by a definition.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user