]> granicus.if.org Git - clang/commitdiff
NFC, Add a test that ensure that we don't emit helper code in copy/dispose
authorAlex Lorenz <arphaman@gmail.com>
Thu, 23 Feb 2017 23:41:50 +0000 (23:41 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Thu, 23 Feb 2017 23:41:50 +0000 (23:41 +0000)
routines for variables that are const-captured

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@296040 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/blocks.c

index 2a8182691156b759eec12e66ad96d4d37453b321..911c63e41d34768448a3db1163314377cff270a2 100644 (file)
@@ -78,3 +78,37 @@ int main() {
 // CHECK: [[ONE:%.*]] = bitcast void (...)* [[ZERO]] to void ()*
 // CHECK-NEXT:   br label [[CE:%.*]]
 
+// Ensure that we don't emit helper code in copy/dispose routines for variables
+// that are const-captured.
+void testConstCaptureInCopyAndDestroyHelpers() {
+  const int x = 0;
+  __block int i;
+  (^ { i = x; })();
+}
+// CHECK-LABEL: testConstCaptureInCopyAndDestroyHelpers_block_invoke
+
+// CHECK: @__copy_helper_block
+// CHECK: alloca
+// CHECK-NEXT: alloca
+// CHECK-NEXT: store
+// CHECK-NEXT: store
+// CHECK-NEXT: load
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: load
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: getelementptr
+// CHECK-NEXT: getelementptr
+// CHECK-NEXT: load
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: call void @_Block_object_assign
+// CHECK-NEXT: ret
+
+// CHECK: @__destroy_helper_block
+// CHECK: alloca
+// CHECK-NEXT: store
+// CHECK-NEXT: load
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: getelementptr
+// CHECK-NEXT: load
+// CHECK-NEXT: call void @_Block_object_dispose
+// CHECK-NEXT: ret