1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -O2 -std=c++11 -disable-llvm-passes -o - %s | FileCheck %s
3 // define{{.*}} void @_Z11simple_moveRU8__strongP11objc_objectS2_
4 void simple_move(__strong id &x, __strong id &y) {
5 // CHECK: = load ptr, ptr
6 // CHECK: store ptr null
7 // CHECK: = load ptr, ptr
9 // CHECK-NEXT: call void @llvm.objc.release
10 x = static_cast<__strong id&&>(y);
11 // CHECK-NEXT: ret void
15 struct remove_reference {
20 struct remove_reference<T&> {
25 struct remove_reference<T&&> {
30 typename remove_reference<T>::type&& move(T &&x) {
31 return static_cast<typename remove_reference<T>::type&&>(x);
34 // CHECK-LABEL: define{{.*}} void @_Z12library_moveRU8__strongP11objc_objectS2_
35 void library_move(__strong id &x, __strong id &y) {
36 // CHECK: call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z4moveIRU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_
37 // CHECK: load ptr, ptr
38 // CHECK: store ptr null, ptr
39 // CHECK: load ptr, ptr
40 // CHECK-NEXT: load ptr, ptr
41 // CHECK-NEXT: store ptr
42 // CHECK-NEXT: call void @llvm.objc.release
43 // CHECK-NEXT: ret void
47 // CHECK-LABEL: define{{.*}} void @_Z12library_moveRU8__strongP11objc_object
48 void library_move(__strong id &y) {
49 // CHECK: [[X:%x]] = alloca ptr, align 8
50 // CHECK: [[I:%.*]] = alloca i32, align 4
51 // CHECK: call void @llvm.lifetime.start.p0(i64 8, ptr [[X]])
52 // CHECK: [[Y:%[a-zA-Z0-9]+]] = call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z4moveIRU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_
54 // CHECK-NEXT: [[OBJ:%[a-zA-Z0-9]+]] = load ptr, ptr [[Y]]
56 // CHECK-NEXT: store ptr null, ptr [[Y]]
57 // Initialize x with the object
58 // CHECK-NEXT: store ptr [[OBJ]], ptr [[X:%[a-zA-Z0-9]+]]
61 // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr [[I]])
62 // CHECK-NEXT: store i32 17
64 // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr [[I]])
65 // CHECK-NEXT: [[OBJ:%[a-zA-Z0-9]+]] = load ptr, ptr [[X]]
66 // CHECK-NEXT: call void @llvm.objc.release(ptr [[OBJ]])
67 // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr [[X]])
68 // CHECK-NEXT: ret void
71 // CHECK-LABEL: define{{.*}} void @_Z10const_moveRU8__strongKP11objc_object(
72 void const_move(const __strong id &x) {
73 // CHECK: [[Y:%y]] = alloca ptr,
74 // CHECK: [[X:%.*]] = call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z4moveIRU8__strongKP11objc_objectEON16remove_referenceIT_E4typeEOS5_(
75 // CHECK-NEXT: [[T0:%.*]] = load ptr, ptr [[X]]
76 // CHECK-NEXT: [[T1:%.*]] = call ptr @llvm.objc.retain(ptr [[T0]])
77 // CHECK-NEXT: store ptr [[T1]], ptr [[Y]]
78 // CHECK-NEXT: [[T0:%.*]] = load ptr, ptr [[Y]]
79 // CHECK-NEXT: call void @llvm.objc.release(ptr [[T0]])