summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorStephen Lin <stephenwlin@gmail.com>2013-06-18 17:00:49 +0000
committerStephen Lin <stephenwlin@gmail.com>2013-06-18 17:00:49 +0000
commita637fb8ccdecd5b0a1171f262b48d62efe9452bd (patch)
treeeb3bc6fd16bde72af833d25a71becd14980e2093 /clang/lib/CodeGen/CodeGenModule.cpp
parentc724765d528eb6bc22dc12774b98dedf2aba1491 (diff)
downloadbcm5719-llvm-a637fb8ccdecd5b0a1171f262b48d62efe9452bd.tar.gz
bcm5719-llvm-a637fb8ccdecd5b0a1171f262b48d62efe9452bd.zip
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp8
1 files changed, 8 insertions, 0 deletions
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.
OpenPOWER on IntegriCloud