r296040 - NFC, Add a test that ensure that we don't emit helper code in copy/dispose
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 23 15:41:50 PST 2017
Author: arphaman
Date: Thu Feb 23 17:41:50 2017
New Revision: 296040
URL: http://llvm.org/viewvc/llvm-project?rev=296040&view=rev
Log:
NFC, Add a test that ensure that we don't emit helper code in copy/dispose
routines for variables that are const-captured
This is a preparation commit that improves code-coverage in code that emits
block copy/dispose routines.
Modified:
cfe/trunk/test/CodeGen/blocks.c
Modified: cfe/trunk/test/CodeGen/blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/blocks.c?rev=296040&r1=296039&r2=296040&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/blocks.c (original)
+++ cfe/trunk/test/CodeGen/blocks.c Thu Feb 23 17:41:50 2017
@@ -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
More information about the cfe-commits
mailing list