diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2018-09-08 20:03:00 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2018-09-08 20:03:00 +0000 |
commit | c500c067925f3be65c645c21ff369e0f8137d0d8 (patch) | |
tree | 640cd0bb22e8f38ddaef038453d3dc9cf4e63604 /test/CodeGenObjCXX/arc-blocks.mm | |
parent | bfe49d565c4fe4c87c797bf4319e7e673ef4dbb2 (diff) |
Distinguish `__block` variables that are captured by escaping blocks
from those that aren't.
This patch changes the way __block variables that aren't captured by
escaping blocks are handled:
- Since non-escaping blocks on the stack never get copied to the heap
(see https://reviews.llvm.org/D49303), Sema shouldn't error out when
the type of a non-escaping __block variable doesn't have an accessible
copy constructor.
- IRGen doesn't have to use the specialized byref structure (see
https://clang.llvm.org/docs/Block-ABI-Apple.html#id8) for a
non-escaping __block variable anymore. Instead IRGen can emit the
variable as a normal variable and copy the reference to the block
literal. Byref copy/dispose helpers aren't needed either.
rdar://problem/39352313
Differential Revision: https://reviews.llvm.org/D51564
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341754 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenObjCXX/arc-blocks.mm')
-rw-r--r-- | test/CodeGenObjCXX/arc-blocks.mm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/test/CodeGenObjCXX/arc-blocks.mm b/test/CodeGenObjCXX/arc-blocks.mm index ef0561bad5..4791aff0b3 100644 --- a/test/CodeGenObjCXX/arc-blocks.mm +++ b/test/CodeGenObjCXX/arc-blocks.mm @@ -3,9 +3,9 @@ // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s // CHECK: [[A:.*]] = type { i64, [10 x i8*] } +// CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 } // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 } // CHECK: %[[STRUCT_TRIVIAL_INTERNAL:.*]] = type { i32 } -// CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 } // CHECK: [[LAYOUT0:@.*]] = private unnamed_addr constant [3 x i8] c" 9\00" @@ -20,6 +20,7 @@ namespace test0 { void foo() { __block A v; + ^{ (void)v; }; } // CHECK-LABEL: define void @_ZN5test03fooEv() // CHECK: [[V:%.*]] = alloca [[BYREF_A:%.*]], align 8 @@ -32,7 +33,8 @@ namespace test0 { // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[V]], i32 0, i32 7 // CHECK-NEXT: call void @_ZN5test01AC1Ev([[A]]* [[T0]]) // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[V]], i32 0, i32 7 - // CHECK-NEXT: [[T1:%.*]] = bitcast [[BYREF_A]]* [[V]] to i8* + // CHECK: bitcast [[BYREF_A]]* [[V]] to i8* + // CHECK: [[T1:%.*]] = bitcast [[BYREF_A]]* [[V]] to i8* // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8) // CHECK-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[T0]]) // CHECK-NEXT: ret void @@ -53,6 +55,11 @@ namespace test0 { // CHECK-NEXT: ret void } +// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_ +// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_ +// CHECK-LABEL-O1: define linkonce_odr hidden void @__copy_helper_block_ +// CHECK-LABEL-O1: define linkonce_odr hidden void @__destroy_helper_block_ + namespace test1 { // Check that copy/dispose helper functions are exception safe. |