aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenObjCXX
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2018-10-01 18:50:14 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2018-10-01 18:50:14 +0000
commitdedd45eb43033375353e464d49e23b43d07e7886 (patch)
treedca063923c0f1eae8855a33e482cbc24ee681295 /test/CodeGenObjCXX
parente130df5734e0870fa0696fce036fb1de6d06fd8d (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. This reapplies r341754, which was reverted in r341757 because it broke a couple of bots. r341754 was calling markEscapingByrefs after the call to PopFunctionScopeInfo, which caused the popped function scope to be cleared out when the following code was compiled, for example: $ cat test.m struct A { id data[10]; }; void foo() { __block A v; ^{ (void)v; }; } This commit calls markEscapingByrefs before calling PopFunctionScopeInfo to prevent that from happening. rdar://problem/39352313 Differential Revision: https://reviews.llvm.org/D51564 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343518 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenObjCXX')
-rw-r--r--test/CodeGenObjCXX/arc-blocks.mm11
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.