From 25a675ef7db4331b01f4ed961311550f582b14b4 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Thu, 23 Feb 2017 23:41:50 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296040 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/blocks.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/CodeGen/blocks.c b/test/CodeGen/blocks.c index 2a81826911..911c63e41d 100644 --- a/test/CodeGen/blocks.c +++ b/test/CodeGen/blocks.c @@ -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 -- 2.50.1