John McCall | d1e40d5 | 2011-10-02 01:16:38 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 2 | |
| 3 | // Test that we're properly retaining lifetime-qualified pointers |
| 4 | // initialized statically and wrapping up those initialization in an |
| 5 | // autorelease pool. |
| 6 | id getObject(); |
| 7 | |
| 8 | // CHECK: define internal void @__cxx_global_var_init |
| 9 | // CHECK: call i8* @_Z9getObjectv |
| 10 | // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue |
| 11 | // CHECK-NEXT: {{store i8*.*@global_obj}} |
| 12 | // CHECK-NEXT: ret void |
| 13 | id global_obj = getObject(); |
| 14 | |
| 15 | // CHECK: define internal void @__cxx_global_var_init |
| 16 | // CHECK: call i8* @_Z9getObjectv |
| 17 | // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue |
| 18 | // CHECK-NEXT: {{store i8*.*@global_obj2}} |
| 19 | // CHECK-NEXT: ret void |
| 20 | id global_obj2 = getObject(); |
| 21 | |
| 22 | // CHECK: define internal void @_GLOBAL__I_a |
| 23 | // CHECK: call i8* @objc_autoreleasePoolPush() |
| 24 | // CHECK-NEXT: call void @__cxx_global_var_init |
| 25 | // CHECK-NEXT: call void @__cxx_global_var_init1 |
| 26 | // CHECK-NEXT: call void @objc_autoreleasePoolPop( |
| 27 | // CHECK-NEXT: ret void |