Eli Friedman | cd7a099 | 2012-02-28 03:32:48 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks -fobjc-arc | FileCheck -check-prefix=ARC %s |
| 2 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks | FileCheck -check-prefix=MRC %s |
| 3 | |
| 4 | typedef int (^fp)(); |
| 5 | fp f() { auto x = []{ return 3; }; return x; } |
| 6 | |
Eli Friedman | 8c72a7d | 2012-03-01 22:52:28 +0000 | [diff] [blame] | 7 | // MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = internal global [5 x i8] c"copy\00" |
| 8 | // MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = internal global [12 x i8] c"autorelease\00" |
Eli Friedman | 23f0267 | 2012-03-01 04:01:32 +0000 | [diff] [blame] | 9 | // MRC: define i32 ()* @_Z1fv( |
Eli Friedman | cd7a099 | 2012-02-28 03:32:48 +0000 | [diff] [blame] | 10 | // MRC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv" |
| 11 | // MRC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*) |
Fariborz Jahanian | 4904bf4 | 2012-06-26 16:06:38 +0000 | [diff] [blame] | 12 | // MRC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke" to i8*) |
Eli Friedman | cd7a099 | 2012-02-28 03:32:48 +0000 | [diff] [blame] | 13 | // MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*) |
| 14 | // MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*) |
| 15 | // MRC: ret i32 ()* |
| 16 | |
Eli Friedman | 23f0267 | 2012-03-01 04:01:32 +0000 | [diff] [blame] | 17 | // ARC: define i32 ()* @_Z1fv( |
Eli Friedman | cd7a099 | 2012-02-28 03:32:48 +0000 | [diff] [blame] | 18 | // ARC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv" |
| 19 | // ARC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*) |
Fariborz Jahanian | 4904bf4 | 2012-06-26 16:06:38 +0000 | [diff] [blame] | 20 | // ARC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke" to i8*) |
Eli Friedman | cd7a099 | 2012-02-28 03:32:48 +0000 | [diff] [blame] | 21 | // ARC: call i8* @objc_retainBlock |
| 22 | // ARC: call i8* @objc_autoreleaseReturnValue |
Eli Friedman | 23f0267 | 2012-03-01 04:01:32 +0000 | [diff] [blame] | 23 | |
| 24 | typedef int (^fp)(); |
| 25 | fp global; |
| 26 | void f2() { global = []{ return 3; }; } |
| 27 | |
Bill Wendling | 8992457 | 2013-02-27 00:06:04 +0000 | [diff] [blame] | 28 | // MRC: define void @_Z2f2v() [[NUW:#[0-9]+]] { |
Fariborz Jahanian | 4904bf4 | 2012-06-26 16:06:38 +0000 | [diff] [blame] | 29 | // MRC: store i8* bitcast (i32 (i8*)* @___Z2f2v_block_invoke to i8*), |
Eli Friedman | 23f0267 | 2012-03-01 04:01:32 +0000 | [diff] [blame] | 30 | // MRC-NOT: call |
| 31 | // MRC: ret void |
| 32 | // ("global" contains a dangling pointer after this function runs.) |
| 33 | |
Bill Wendling | 8992457 | 2013-02-27 00:06:04 +0000 | [diff] [blame] | 34 | // ARC: define void @_Z2f2v() [[NUW:#[0-9]+]] { |
Fariborz Jahanian | 4904bf4 | 2012-06-26 16:06:38 +0000 | [diff] [blame] | 35 | // ARC: store i8* bitcast (i32 (i8*)* @___Z2f2v_block_invoke to i8*), |
Eli Friedman | 23f0267 | 2012-03-01 04:01:32 +0000 | [diff] [blame] | 36 | // ARC: call i8* @objc_retainBlock |
| 37 | // ARC: call void @objc_release |
Fariborz Jahanian | 4904bf4 | 2012-06-26 16:06:38 +0000 | [diff] [blame] | 38 | // ARC: define internal i32 @___Z2f2v_block_invoke |
Eli Friedman | 23f0267 | 2012-03-01 04:01:32 +0000 | [diff] [blame] | 39 | // ARC: call i32 @"_ZZ2f2vENK3$_1clEv |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame] | 40 | |
Bill Wendling | 8992457 | 2013-02-27 00:06:04 +0000 | [diff] [blame] | 41 | // ARC: attributes [[NUW]] = { nounwind{{.*}} } |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame] | 42 | |
Bill Wendling | 8992457 | 2013-02-27 00:06:04 +0000 | [diff] [blame] | 43 | // MRC: attributes [[NUW]] = { nounwind{{.*}} } |