Akira Hatanaka | e974479 | 2017-09-20 06:32:45 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fblocks -emit-llvm -o - %s | FileCheck %s |
| 2 | |
| 3 | typedef void (^BlockTy)(void); |
| 4 | |
| 5 | union U { |
| 6 | int *i; |
| 7 | long long *ll; |
| 8 | } __attribute__((transparent_union)); |
| 9 | |
| 10 | void noescapeFunc0(id, __attribute__((noescape)) BlockTy); |
| 11 | void noescapeFunc1(__attribute__((noescape)) int *); |
| 12 | void noescapeFunc2(__attribute__((noescape)) id); |
| 13 | void noescapeFunc3(__attribute__((noescape)) union U); |
| 14 | |
| 15 | // CHECK-LABEL: define void @test0( |
| 16 | // CHECK: call void @noescapeFunc0({{.*}}, {{.*}} nocapture {{.*}}) |
| 17 | // CHECK: declare void @noescapeFunc0(i8*, {{.*}} nocapture) |
| 18 | void test0(BlockTy b) { |
| 19 | noescapeFunc0(0, b); |
| 20 | } |
| 21 | |
| 22 | // CHECK-LABEL: define void @test1( |
| 23 | // CHECK: call void @noescapeFunc1({{.*}} nocapture {{.*}}) |
| 24 | // CHECK: declare void @noescapeFunc1({{.*}} nocapture) |
| 25 | void test1(int *i) { |
| 26 | noescapeFunc1(i); |
| 27 | } |
| 28 | |
| 29 | // CHECK-LABEL: define void @test2( |
| 30 | // CHECK: call void @noescapeFunc2({{.*}} nocapture {{.*}}) |
| 31 | // CHECK: declare void @noescapeFunc2({{.*}} nocapture) |
| 32 | void test2(id i) { |
| 33 | noescapeFunc2(i); |
| 34 | } |
| 35 | |
| 36 | // CHECK-LABEL: define void @test3( |
| 37 | // CHECK: call void @noescapeFunc3({{.*}} nocapture {{.*}}) |
| 38 | // CHECK: declare void @noescapeFunc3({{.*}} nocapture) |
| 39 | void test3(union U u) { |
| 40 | noescapeFunc3(u); |
| 41 | } |
| 42 | |
| 43 | // CHECK: define internal void @"\01-[C0 m0:]"({{.*}}, {{.*}}, {{.*}} nocapture {{.*}}) |
| 44 | |
| 45 | // CHECK-LABEL: define void @test4( |
| 46 | // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32*)*)(i8* {{.*}}, i8* {{.*}}, i32* nocapture {{.*}}) |
| 47 | |
| 48 | @interface C0 |
| 49 | -(void) m0:(int*)__attribute__((noescape)) p0; |
| 50 | @end |
| 51 | |
| 52 | @implementation C0 |
| 53 | -(void) m0:(int*)__attribute__((noescape)) p0 { |
| 54 | } |
| 55 | @end |
| 56 | |
| 57 | void test4(C0 *c0, int *p) { |
| 58 | [c0 m0:p]; |
| 59 | } |
| 60 | |
| 61 | // CHECK-LABEL: define void @test5( |
| 62 | // CHECK: call void {{.*}}(i8* bitcast ({ i8**, i32, i32, i8*, {{.*}} }* @{{.*}} to i8*), i32* nocapture {{.*}}) |
| 63 | // CHECK: call void {{.*}}(i8* {{.*}}, i32* nocapture {{.*}}) |
| 64 | // CHECK: define internal void @{{.*}}(i8* {{.*}}, i32* nocapture {{.*}}) |
| 65 | |
| 66 | typedef void (^BlockTy2)(__attribute__((noescape)) int *); |
| 67 | |
| 68 | void test5(BlockTy2 b, int *p) { |
| 69 | ^(int *__attribute__((noescape)) p0){}(p); |
| 70 | b(p); |
| 71 | } |