1 // RUN: %clang_cc1 -triple armv7-unknown-linux-gnueabihf %s -o - -emit-llvm -O2 | FileCheck %s
3 // Stack should be reused when possible, no need to allocate two separate slots
4 // if they have disjoint lifetime.
6 // Sizes of objects are related to previously existed threshold of 32. In case
7 // of S_large stack size is rounded to 40 bytes.
19 // Helper class for lifetime scope absence testing
27 extern S_small
foo_small();
28 extern S_large
foo_large();
29 extern void bar_small(S_small
*);
30 extern void bar_large(S_large
*);
32 // Prevent mangling of function names.
35 void small_rvoed_unnamed_temporary_object() {
36 // CHECK-LABEL: define{{.*}} void @small_rvoed_unnamed_temporary_object
37 // CHECK: call void @llvm.lifetime.start
38 // CHECK: call void @_Z9foo_smallv
39 // CHECK: call void @llvm.lifetime.end
40 // CHECK: call void @llvm.lifetime.start
41 // CHECK: call void @_Z9foo_smallv
42 // CHECK: call void @llvm.lifetime.end
48 void large_rvoed_unnamed_temporary_object() {
49 // CHECK-LABEL: define{{.*}} void @large_rvoed_unnamed_temporary_object
50 // CHECK: call void @llvm.lifetime.start
51 // CHECK: call void @_Z9foo_largev
52 // CHECK: call void @llvm.lifetime.end
53 // CHECK: call void @llvm.lifetime.start
54 // CHECK: call void @_Z9foo_largev
55 // CHECK: call void @llvm.lifetime.end
61 void small_rvoed_named_temporary_object() {
62 // CHECK-LABEL: define{{.*}} void @small_rvoed_named_temporary_object
63 // CHECK: call void @llvm.lifetime.start
64 // CHECK: call void @_Z9foo_smallv
65 // CHECK: call void @llvm.lifetime.end
66 // CHECK: call void @llvm.lifetime.start
67 // CHECK: call void @_Z9foo_smallv
68 // CHECK: call void @llvm.lifetime.end
71 S_small s
= foo_small();
74 S_small s
= foo_small();
78 void large_rvoed_named_temporary_object() {
79 // CHECK-LABEL: define{{.*}} void @large_rvoed_named_temporary_object
80 // CHECK: call void @llvm.lifetime.start
81 // CHECK: call void @_Z9foo_largev
82 // CHECK: call void @llvm.lifetime.end
83 // CHECK: call void @llvm.lifetime.start
84 // CHECK: call void @_Z9foo_largev
85 // CHECK: call void @llvm.lifetime.end
88 S_large s
= foo_large();
91 S_large s
= foo_large();
95 void small_auto_object() {
96 // CHECK-LABEL: define{{.*}} void @small_auto_object
97 // CHECK: call void @llvm.lifetime.start
98 // CHECK: call void @_Z9bar_smallP7S_small
99 // CHECK: call void @llvm.lifetime.end
100 // CHECK: call void @llvm.lifetime.start
101 // CHECK: call void @_Z9bar_smallP7S_small
102 // CHECK: call void @llvm.lifetime.end
114 void large_auto_object() {
115 // CHECK-LABEL: define{{.*}} void @large_auto_object
116 // CHECK: call void @llvm.lifetime.start
117 // CHECK: call void @_Z9bar_largeP7S_large
118 // CHECK: call void @llvm.lifetime.end
119 // CHECK: call void @llvm.lifetime.start
120 // CHECK: call void @_Z9bar_largeP7S_large
121 // CHECK: call void @llvm.lifetime.end
133 int large_combiner_test(S_large s
) {
134 // CHECK-LABEL: define{{.*}} i32 @large_combiner_test
135 // CHECK: [[T2:%.*]] = alloca %struct.Combiner
136 // CHECK: [[T1:%.*]] = alloca %struct.Combiner
137 // CHECK: [[T3:%.*]] = call noundef ptr @_ZN8CombinerC1E7S_large(ptr {{[^,]*}} [[T1]], [9 x i32] %s.coerce)
138 // CHECK: call void @_ZN8Combiner1fEv(ptr nonnull sret(%struct.Combiner) align 4 [[T2]], ptr {{[^,]*}} [[T1]])
139 // CHECK: [[T5:%.*]] = load i32, ptr [[T2]]
140 // CHECK: ret i32 [[T5]]
142 return Combiner(s
).f().a
.a
[0];