|
@@ -8,6 +8,7 @@ union U {
|
|
|
long long *ll;
|
|
|
} __attribute__((transparent_union));
|
|
|
|
|
|
+void escapingFunc0(BlockTy);
|
|
|
void noescapeFunc0(id, __attribute__((noescape)) BlockTy);
|
|
|
void noescapeFunc1(__attribute__((noescape)) int *);
|
|
|
void noescapeFunc2(__attribute__((noescape)) id);
|
|
@@ -21,6 +22,9 @@ void noescapeFunc3(__attribute__((noescape)) union U);
|
|
|
// When the block is non-escaping, copy/dispose helpers aren't generated, so the
|
|
|
// block layout string must include information about __strong captures.
|
|
|
|
|
|
+// CHECK-NOARC: %[[STRUCT_BLOCK_BYREF_B0:.*]] = type { i8*, %[[STRUCT_BLOCK_BYREF_B0]]*, i32, i32, i8*, %[[STRUCT_S0:.*]] }
|
|
|
+// CHECK-ARC: %[[STRUCT_BLOCK_BYREF_B0:.*]] = type { i8*, %[[STRUCT_BLOCK_BYREF_B0]]*, i32, i32, i8*, i8*, i8*, %[[STRUCT_S0:.*]] }
|
|
|
+// CHECK: %[[STRUCT_S0]] = type { i8*, i8* }
|
|
|
// CHECK: @[[BLOCK_DESCIPTOR_TMP_2:.*ls32l8"]] = linkonce_odr hidden unnamed_addr constant { i64, i64, i8*, i64 } { i64 0, i64 40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 256 }, align 8
|
|
|
|
|
|
// CHECK-LABEL: define void @test0(
|
|
@@ -102,7 +106,7 @@ void test5(BlockTy2 b, int *p) {
|
|
|
// CHECK-NOARC: %[[V1:.*]] = load i8*, i8** %[[B_ADDR]], align 8
|
|
|
// CHECK-NOARC: store i8* %[[V1]], i8** %[[BLOCK_CAPTURED]], align 8
|
|
|
// CHECK-ARC: %[[V2:.*]] = load i8*, i8** %[[B_ADDR]], align 8
|
|
|
-// CHECK-ARC: %[[V3:.*]] = call i8* @objc_retain(i8* %[[V2]]) #3
|
|
|
+// CHECK-ARC: %[[V3:.*]] = call i8* @objc_retain(i8* %[[V2]])
|
|
|
// CHECK-ARC: store i8* %[[V3]], i8** %[[BLOCK_CAPTURED]], align 8
|
|
|
// CHECK: call void @noescapeFunc0(
|
|
|
// CHECK-ARC: call void @objc_storeStrong(i8** %[[V0]], i8* null)
|
|
@@ -118,3 +122,49 @@ void func(id);
|
|
|
void test6(id a, id b) {
|
|
|
noescapeFunc0(a, ^{ func(b); });
|
|
|
}
|
|
|
+
|
|
|
+// We don't need either the byref helper functions or the byref structs for
|
|
|
+// __block variables that are not captured by escaping blocks.
|
|
|
+
|
|
|
+// CHECK: define void @test7(
|
|
|
+// CHECK: alloca i8*, align 8
|
|
|
+// CHECK: %[[B0:.*]] = alloca i8*, align 8
|
|
|
+// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>, align 8
|
|
|
+// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>* %[[BLOCK]], i32 0, i32 5
|
|
|
+// CHECK: store i8** %[[B0]], i8*** %[[BLOCK_CAPTURED]], align 8
|
|
|
+
|
|
|
+// CHECK-ARC-NOT: define internal void @__Block_byref_object_copy_
|
|
|
+// CHECK-ARC-NOT: define internal void @__Block_byref_object_dispose_
|
|
|
+
|
|
|
+void test7() {
|
|
|
+ id a;
|
|
|
+ __block id b0;
|
|
|
+ noescapeFunc0(a, ^{ (void)b0; });
|
|
|
+}
|
|
|
+
|
|
|
+// __block variables captured by escaping blocks need byref helper functions.
|
|
|
+
|
|
|
+// CHECK: define void @test8(
|
|
|
+// CHECK: %[[A:.*]] = alloca i8*, align 8
|
|
|
+// CHECK: %[[B0:.*]] = alloca %[[STRUCT_BLOCK_BYREF_B0]], align 8
|
|
|
+// CHECK: alloca <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, align 8
|
|
|
+// CHECK: %[[BLOCK1:.*]] = alloca <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, align 8
|
|
|
+// CHECK: %[[BLOCK_CAPTURED7:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK1]], i32 0, i32 5
|
|
|
+// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_BLOCK_BYREF_B0]]* %[[B0]] to i8*
|
|
|
+// CHECK: store i8* %[[V3]], i8** %[[BLOCK_CAPTURED7]], align 8
|
|
|
+
|
|
|
+// CHECK-ARC: define internal void @__Block_byref_object_copy_
|
|
|
+// CHECK-ARC: define internal void @__Block_byref_object_dispose_
|
|
|
+// CHECK: define linkonce_odr hidden void @__copy_helper_block_
|
|
|
+// CHECK: define linkonce_odr hidden void @__destroy_helper_block_
|
|
|
+
|
|
|
+struct S0 {
|
|
|
+ id a, b;
|
|
|
+};
|
|
|
+
|
|
|
+void test8() {
|
|
|
+ id a;
|
|
|
+ __block struct S0 b0;
|
|
|
+ noescapeFunc0(a, ^{ (void)b0; });
|
|
|
+ escapingFunc0(^{ (void)b0; });
|
|
|
+}
|