summaryrefslogtreecommitdiffstats
path: root/test/CodeGenObjC
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-02-24 00:09:30 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-02-24 00:09:30 +0000
commit502326209304ffddbd996f8d323cd3d7ad0dbacd (patch)
treeef842155291b7cbbd676ca27540ddff789dbe3ec /test/CodeGenObjC
parent25a675ef7db4331b01f4ed961311550f582b14b4 (diff)
NFC, Add a test that ensures that we don't emit helper code in copy/dispose
routines for objects that are captured with the __unsafe_unretained ownership qualifier This is a preparation commit that improves code-coverage in code that emits block copy/dispose routines. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296048 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenObjC')
-rw-r--r--test/CodeGenObjC/arc-blocks.m35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/CodeGenObjC/arc-blocks.m b/test/CodeGenObjC/arc-blocks.m
index f67136b7b2..06eb46b867 100644
--- a/test/CodeGenObjC/arc-blocks.m
+++ b/test/CodeGenObjC/arc-blocks.m
@@ -667,6 +667,41 @@ void test18(id x) {
// CHECK-UNOPT-NEXT: ret void
}
+// Ensure that we don't emit helper code in copy/dispose routines for variables
+// that are const-captured.
+void testUnsafeUnretainedLifetimeInCopyAndDestroyHelpers(id x, id y) {
+ id __unsafe_unretained unsafeObject = x;
+ (^ { testUnsafeUnretainedLifetimeInCopyAndDestroyHelpers(x, unsafeObject); })();
+}
+
+// CHECK-LABEL: testUnsafeUnretainedLifetimeInCopyAndDestroyHelpers_block_invoke
+// CHECK-UNOPT-LABEL: testUnsafeUnretainedLifetimeInCopyAndDestroyHelpers_block_invoke
+
+// CHECK-UNOPT: @__copy_helper_block
+// CHECK-UNOPT: alloca
+// CHECK-UNOPT-NEXT: alloca
+// CHECK-UNOPT-NEXT: store
+// CHECK-UNOPT-NEXT: store
+// CHECK-UNOPT-NEXT: load
+// CHECK-UNOPT-NEXT: bitcast
+// CHECK-UNOPT-NEXT: load
+// CHECK-UNOPT-NEXT: bitcast
+// CHECK-UNOPT-NEXT: getelementptr
+// CHECK-UNOPT-NEXT: getelementptr
+// CHECK-UNOPT-NEXT: load
+// CHECK-UNOPT-NEXT: store
+// CHECK-UNOPT-NEXT: call void @objc_storeStrong
+// CHECK-UNOPT-NEXT: ret
+
+// CHECK-UNOPT: @__destroy_helper_block
+// CHECK-UNOPT: alloca
+// CHECK-UNOPT-NEXT: store
+// CHECK-UNOPT-NEXT: load
+// CHECK-UNOPT-NEXT: bitcast
+// CHECK-UNOPT-NEXT: getelementptr
+// CHECK-UNOPT-NEXT: call void @objc_storeStrong
+// CHECK-UNOPT-NEXT: ret
+
// rdar://13588325
void test19_sink(void (^)(int));
void test19(void (^b)(void)) {