Mehdi Amini | 06d367c | 2016-10-24 20:39:34 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 | FileCheck %s |
| 2 | |
| 3 | // Make sure we emit clang.arc.use before calling objc_release as part of the |
| 4 | // cleanup. This way we make sure the object will not be released until the |
| 5 | // end of the full expression. |
| 6 | |
| 7 | // rdar://problem/24528966 |
| 8 | |
| 9 | @class NSString; |
| 10 | extern __attribute__((visibility("default"))) NSString *GenString(); |
| 11 | |
| 12 | // Behavior of __builtin_os_log differs between platforms, so only test on X86 |
| 13 | #ifdef __x86_64__ |
| 14 | // CHECK-LABEL: define i8* @test_builtin_os_log |
| 15 | void *test_builtin_os_log(void *buf) { |
| 16 | return __builtin_os_log_format(buf, "capabilities: %@", GenString()); |
| 17 | |
| 18 | // CHECK: store i8 2, i8* |
| 19 | // CHECK: [[NUM_ARGS:%.*]] = getelementptr i8, i8* {{.*}}, i64 1 |
| 20 | // CHECK: store i8 1, i8* [[NUM_ARGS]] |
| 21 | // |
| 22 | // CHECK: [[ARG1_DESC:%.*]] = getelementptr i8, i8* {{.*}}, i64 2 |
| 23 | // CHECK: store i8 64, i8* [[ARG1_DESC]] |
| 24 | // CHECK: [[ARG1_SIZE:%.*]] = getelementptr i8, i8* {{.*}}, i64 3 |
| 25 | // CHECK: store i8 8, i8* [[ARG1_SIZE]] |
| 26 | // CHECK: [[ARG1:%.*]] = getelementptr i8, i8* {{.*}}, i64 4 |
| 27 | // CHECK: [[ARG1_CAST:%.*]] = bitcast i8* [[ARG1]] to |
| 28 | |
| 29 | // CHECK: [[STRING:%.*]] = {{.*}} call {{.*}} @GenString() |
| 30 | // CHECK: [[STRING_CAST:%.*]] = bitcast {{.*}} [[STRING]] to |
| 31 | // CHECK: call {{.*}} @objc_retainAutoreleasedReturnValue(i8* [[STRING_CAST]]) |
| 32 | // CHECK: store {{.*}} [[STRING]], {{.*}} [[ARG1_CAST]] |
| 33 | |
| 34 | // CHECK: call void (...) @clang.arc.use({{.*}} [[STRING]]) |
| 35 | // CHECK: call void @objc_release(i8* [[STRING_CAST]]) |
| 36 | // CHECK: ret i8* |
| 37 | } |
| 38 | |
| 39 | #endif |