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 | 2e00b98027b51ee5bfb88a4daea8b78bf9a01e62 (patch) | |
tree | f3d7abea73167f1aae4c974d890ed608e5c41e7f /clang/test/CodeGen | |
parent | 7af5e333e7f9ae0a74d86c81babd99006c12a83b (diff) | |
download | bcm5719-llvm-2e00b98027b51ee5bfb88a4daea8b78bf9a01e62.tar.gz bcm5719-llvm-2e00b98027b51ee5bfb88a4daea8b78bf9a01e62.zip |
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
llvm-svn: 341754
Diffstat (limited to 'clang/test/CodeGen')
-rw-r--r-- | clang/test/CodeGen/block-byref-aggr.c | 4 | ||||
-rw-r--r-- | clang/test/CodeGen/blocks-seq.c | 1 | ||||
-rw-r--r-- | clang/test/CodeGen/exceptions.c | 1 | ||||
-rw-r--r-- | clang/test/CodeGen/personality.c | 1 |
4 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/CodeGen/block-byref-aggr.c b/clang/test/CodeGen/block-byref-aggr.c index 962f100638f..db105768993 100644 --- a/clang/test/CodeGen/block-byref-aggr.c +++ b/clang/test/CodeGen/block-byref-aggr.c @@ -9,11 +9,13 @@ Agg makeAgg(void); // cause a block copy. rdar://9309454 void test0() { __block Agg a = {100}; + ^{ (void)a; }; a = makeAgg(); } // CHECK-LABEL: define void @test0() // CHECK: [[A:%.*]] = alloca [[BYREF:%.*]], align 8 +// CHECK-NEXT: alloca <{ i8*, i32, i32, i8*, %{{.*}}*, i8* }>, align 8 // CHECK-NEXT: [[TEMP:%.*]] = alloca [[AGG]], align 4 // CHECK: [[RESULT:%.*]] = call i32 @makeAgg() // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[TEMP]], i32 0, i32 0 @@ -35,11 +37,13 @@ void test0() { // rdar://11757470 void test1() { __block Agg a, b; + ^{ (void)a; (void)b; }; a = b = makeAgg(); } // CHECK-LABEL: define void @test1() // CHECK: [[A:%.*]] = alloca [[A_BYREF:%.*]], align 8 // CHECK-NEXT: [[B:%.*]] = alloca [[B_BYREF:%.*]], align 8 +// CHECK-NEXT: alloca <{ i8*, i32, i32, i8*, %{{.*}}*, i8*, i8* }>, align 8 // CHECK-NEXT: [[TEMP:%.*]] = alloca [[AGG]], align 4 // CHECK: [[RESULT:%.*]] = call i32 @makeAgg() // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[TEMP]], i32 0, i32 0 diff --git a/clang/test/CodeGen/blocks-seq.c b/clang/test/CodeGen/blocks-seq.c index b3e672976ca..9b47fbf783d 100644 --- a/clang/test/CodeGen/blocks-seq.c +++ b/clang/test/CodeGen/blocks-seq.c @@ -11,6 +11,7 @@ int rhs(); void foo() { __block int i; + ^{ (void)i; }; i = rhs(); i += rhs(); } diff --git a/clang/test/CodeGen/exceptions.c b/clang/test/CodeGen/exceptions.c index 039ec84d2e5..57b869196ba 100644 --- a/clang/test/CodeGen/exceptions.c +++ b/clang/test/CodeGen/exceptions.c @@ -23,6 +23,7 @@ void test1() { void test2_helper(); void test2() { __block int x = 10; + ^{ (void)x; }; test2_helper(5, 6, 7); } void test2_helper(int x, int y) { diff --git a/clang/test/CodeGen/personality.c b/clang/test/CodeGen/personality.c index 1c533ce786c..59a6a9ccd69 100644 --- a/clang/test/CodeGen/personality.c +++ b/clang/test/CodeGen/personality.c @@ -26,6 +26,7 @@ extern void i(void); void f(void) { __block int i; + ^{ (void)i; }; g(^ { }); } |