1 // RUN: %clang_cc1 -std=gnu++98 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-arc-exceptions -O2 -disable-llvm-passes -o - %s | FileCheck %s
3 #include "literal-support.h"
17 // CHECK-LABEL: define{{.*}} void @_Z10test_arrayv
19 // CHECK: [[ARR:%[a-zA-Z0-9.]+]] = alloca ptr
20 // CHECK: [[OBJECTS:%[a-zA-Z0-9.]+]] = alloca [2 x ptr]
21 // CHECK: [[TMPX:%[a-zA-Z0-9.]+]] = alloca %
22 // CHECK: [[TMPY:%[a-zA-Z0-9.]+]] = alloca %
24 // Initializing first element
25 // CHECK: call void @llvm.lifetime.start.p0(i64 8, ptr [[ARR]])
26 // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x ptr], ptr [[OBJECTS]], i64 0, i64 0
27 // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr [[TMPX]])
28 // CHECK-NEXT: call void @_ZN1XC1Ev({{.*}} [[TMPX]])
29 // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke noundef ptr @_ZNK1XcvP11objc_objectEv{{.*}} [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
30 // CHECK: store ptr [[OBJECT0]], ptr [[ELEMENT0]]
32 // Initializing the second element
33 // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x ptr], ptr [[OBJECTS]], i64 0, i64 1
34 // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr [[TMPY]])
35 // CHECK-NEXT: invoke void @_ZN1YC1Ev({{.*}} [[TMPY]])
36 // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke noundef ptr @_ZNK1YcvP11objc_objectEv{{.*}} [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
37 // CHECK: store ptr [[OBJECT1]], ptr [[ELEMENT1]]
40 // CHECK: {{invoke.*@objc_msgSend}}{{.*}} [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
41 id arr = @[ X(), Y() ];
43 // Destroy temporaries
44 // CHECK-NOT: ret void
45 // CHECK: call void @llvm.objc.release
46 // CHECK-NOT: ret void
47 // CHECK: invoke void @_ZN1YD1Ev
48 // CHECK-NOT: ret void
49 // CHECK: call void @llvm.objc.release
50 // CHECK-NEXT: call void @_ZN1XD1Ev
51 // CHECK-NOT: ret void
52 // CHECK: call void @llvm.objc.release
53 // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr [[ARR]])
54 // CHECK-NEXT: ret void
57 // CHECK: call void @llvm.objc.release
58 // CHECK-NOT: call void @llvm.objc.release
59 // CHECK: invoke void @_ZN1YD1Ev
60 // CHECK: call void @llvm.objc.release
61 // CHECK-NOT: call void @llvm.objc.release
62 // CHECK: invoke void @_ZN1XD1Ev
63 // CHECK-NOT: call void @llvm.objc.release
67 // CHECK-LABEL: define weak_odr void @_Z24test_array_instantiationIiEvv
69 void test_array_instantiation() {
70 // CHECK: [[ARR:%[a-zA-Z0-9.]+]] = alloca ptr
71 // CHECK: [[OBJECTS:%[a-zA-Z0-9.]+]] = alloca [2 x ptr]
73 // Initializing first element
74 // CHECK: call void @llvm.lifetime.start.p0(i64 8, ptr [[ARR]])
75 // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x ptr], ptr [[OBJECTS]], i64 0, i64 0
76 // CHECK: call void @_ZN1XC1Ev
77 // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke noundef ptr @_ZNK1XcvP11objc_objectEv{{.*}} [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
78 // CHECK: store ptr [[OBJECT0]], ptr [[ELEMENT0]]
80 // Initializing the second element
81 // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x ptr], ptr [[OBJECTS]], i64 0, i64 1
82 // CHECK: invoke void @_ZN1YC1Ev
83 // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke noundef ptr @_ZNK1YcvP11objc_objectEv{{.*}} [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
84 // CHECK: store ptr [[OBJECT1]], ptr [[ELEMENT1]]
87 // CHECK: {{invoke.*@objc_msgSend}}{{.*}} [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
88 id arr = @[ X(), Y() ];
90 // Destroy temporaries
91 // CHECK-NOT: ret void
92 // CHECK: call void @llvm.objc.release
93 // CHECK-NOT: ret void
94 // CHECK: invoke void @_ZN1YD1Ev
95 // CHECK-NOT: ret void
96 // CHECK: call void @llvm.objc.release
97 // CHECK-NEXT: call void @_ZN1XD1Ev
98 // CHECK-NOT: ret void
99 // CHECK: call void @llvm.objc.release
100 // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr [[ARR]])
101 // CHECK-NEXT: ret void
104 // CHECK: call void @llvm.objc.release
105 // CHECK-NOT: call void @llvm.objc.release
106 // CHECK: invoke void @_ZN1YD1Ev
107 // CHECK: call void @llvm.objc.release
108 // CHECK-NOT: call void @llvm.objc.release
109 // CHECK: invoke void @_ZN1XD1Ev
110 // CHECK-NOT: call void @llvm.objc.release
111 // CHECK: unreachable
114 template void test_array_instantiation<int>();