summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGObjC.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2017-04-28 18:50:57 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2017-04-28 18:50:57 +0000
commita6b6dcc12384359b0e9a5843ec8e69ff3dc28009 (patch)
tree442e88773ef7214cc66949728e2c35031a589de4 /clang/lib/CodeGen/CGObjC.cpp
parent6652a52e2b208ad593ff562667142affaec4a7df (diff)
downloadbcm5719-llvm-a6b6dcc12384359b0e9a5843ec8e69ff3dc28009.tar.gz
bcm5719-llvm-a6b6dcc12384359b0e9a5843ec8e69ff3dc28009.zip
[CodeGen][ObjC] Don't retain captured Objective-C pointers at block
creation that are const-qualified. When a block captures an ObjC object pointer, clang retains the pointer to prevent prematurely destroying the object the pointer points to before the block is called or copied. When the captured object pointer is const-qualified, we can avoid emitting the retain/release pair since the pointer variable cannot be modified in the scope in which the block literal is introduced. For example: void test(const id x) { callee(^{ (void)x; }); } This patch implements that optimization. rdar://problem/28894510 Differential Revision: https://reviews.llvm.org/D32601 llvm-svn: 301667
Diffstat (limited to 'clang/lib/CodeGen/CGObjC.cpp')
-rw-r--r--clang/lib/CodeGen/CGObjC.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 76e7df861f7..f4fbab3c2b8 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -2415,6 +2415,12 @@ void CodeGenFunction::destroyARCWeak(CodeGenFunction &CGF,
CGF.EmitARCDestroyWeak(addr);
}
+void CodeGenFunction::emitARCIntrinsicUse(CodeGenFunction &CGF, Address addr,
+ QualType type) {
+ llvm::Value *value = CGF.Builder.CreateLoad(addr);
+ CGF.EmitARCIntrinsicUse(value);
+}
+
namespace {
struct CallObjCAutoreleasePoolObject final : EHScopeStack::Cleanup {
llvm::Value *Token;
OpenPOWER on IntegriCloud