]> granicus.if.org Git - clang/commitdiff
NFC, Add a test that ensures that we don't emit helper code in copy/dispose
authorAlex Lorenz <arphaman@gmail.com>
Fri, 24 Feb 2017 00:09:30 +0000 (00:09 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Fri, 24 Feb 2017 00:09:30 +0000 (00:09 +0000)
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

test/CodeGenObjC/arc-blocks.m

index f67136b7b226ab3ebaa0349b166c920f04a35dad..06eb46b867d2fd6b021e370ec0c842ca7e2c36f8 100644 (file)
@@ -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)) {