From a637fb8ccdecd5b0a1171f262b48d62efe9452bd Mon Sep 17 00:00:00 2001 From: Stephen Lin Date: Tue, 18 Jun 2013 17:00:49 +0000 Subject: 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 --- clang/lib/CodeGen/CodeGenModule.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 824d2a04662..d76fee5c844 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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. -- cgit v1.2.3