1 // RUN: %clang_cc1 -std=c++11 -triple i386-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-darwin -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
3 // RUN: %clang_cc1 -std=c++11 -triple arm64-ehabi -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
4 // RUN: %clang_cc1 -std=c++11 -triple i386-windows -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI --check-prefix=WIN32
5 // RUN: %clang_cc1 -std=c++11 -triple x86_64-windows -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI --check-prefix=WIN64
6
7 // PR12219
8 struct A { A(int); virtual ~A(); };
9 struct B : A { using A::A; ~B(); };
~B()10 B::~B() {}
11
12 B b(123);
13
14 struct C { template<typename T> C(T); };
15 struct D : C { using C::C; };
16 D d(123);
17
18 // ITANIUM-LABEL: define void @_ZN1BD2Ev
19 // ITANIUM-LABEL: define void @_ZN1BD1Ev
20 // ITANIUM-LABEL: define void @_ZN1BD0Ev
21 // WIN32-LABEL: define {{.*}}void @"\01??1B@@UAE@XZ"
22 // WIN64-LABEL: define {{.*}}void @"\01??1B@@UEAA@XZ"
23
24 // ITANIUM-LABEL: define linkonce_odr void @_ZN1BCI11AEi(
25 // ITANIUM: call void @_ZN1BCI21AEi(
26
27 // ITANIUM-LABEL: define linkonce_odr void @_ZN1DCI11CIiEET_(
28 // ITANIUM: call void @_ZN1DCI21CIiEET_(
29
30 // WIN32-LABEL: define internal {{.*}} @"\01??0B@@QAE@H@Z"(
31 // WIN32: call {{.*}} @"\01??0A@@QAE@H@Z"(
32 // WIN64-LABEL: define internal {{.*}} @"\01??0B@@QEAA@H@Z"(
33 // WIN64: call {{.*}} @"\01??0A@@QEAA@H@Z"(
34
35 // WIN32-LABEL: define internal {{.*}} @"\01??0D@@QAE@H@Z"(
36 // WIN32: call {{.*}} @"\01??$?0H@C@@QAE@H@Z"
37 // WIN64-LABEL: define internal {{.*}} @"\01??0D@@QEAA@H@Z"(
38 // WIN64: call {{.*}} @"\01??$?0H@C@@QEAA@H@Z"
39
40 struct Q { Q(int); Q(const Q&); ~Q(); };
41 struct Z { Z(); Z(int); ~Z(); int n; };
42
43 namespace noninline_nonvirt {
44 struct A { A(int, Q&&, void *__attribute__((pass_object_size(0)))); int n; };
45 struct B : Z, A { Z z; using A::A; };
46 B b(1, 2, &b);
47 // ITANIUM-LABEL: define {{.*}} @__cxx_global_var_init
48 // ITANIUM: call void @_ZN1QC1Ei({{.*}} %[[TMP:.*]], i32 2)
49 // ITANIUM: call void @_ZN17noninline_nonvirt1BCI1NS_1AEEiO1QPvU17pass_object_size0({{.*}} @_ZN17noninline_nonvirt1bE, i32 1, {{.*}} %[[TMP]], i8* {{.*}} @_ZN17noninline_nonvirt1bE{{.*}}, i{{32|64}} 12)
50 // ITANIUM: call void @_ZN1QD1Ev({{.*}} %[[TMP]])
51 // ITANIUM: call i32 @__cxa_atexit(
52
53 // Complete object ctor for B delegates to base object ctor.
54 // ITANIUM-LABEL: define linkonce_odr void @_ZN17noninline_nonvirt1BCI1NS_1AEEiO1QPvU17pass_object_size0(
55 // ITANIUM: call void @_ZN17noninline_nonvirt1BCI2NS_1AEEiO1QPvU17pass_object_size0({{.*}}, i32 {{.*}}, %{{.*}}* {{.*}}, i8* {{.*}}, i{{32|64}} {{.*}})
56
57 // In MSABI, we don't have ctor variants. B ctor forwards to A ctor.
58 // MSABI-LABEL: define internal {{.*}} @"\01??0B@noninline_nonvirt@@Q{{AE|EAA}}@H$$Q{{E?}}AUQ@@P{{E?}}AXW4__pass_object_size0@__clang@@@Z"(%{{.*}}, i32{{.*}}, %{{.*}}, i8*{{.*}}, i{{32|64}}{{.*}})
59 // MSABI: call {{.*}} @"\01??0Z@@Q{{AE|EAA}}@XZ"(
60 // MSABI: call {{.*}} @"\01??0A@noninline_nonvirt@@Q{{AE|EAA}}@H$$Q{{E?}}AUQ@@P{{E?}}AXW4__pass_object_size0@__clang@@@Z"(%{{.*}}, i32{{.*}}, %{{.*}}, i8*{{.*}}, i{{32|64}}{{.*}})
61 // MSABI: call {{.*}} @"\01??0Z@@Q{{AE|EAA}}@XZ"(
62
63 struct C : B { using B::B; };
64 C c(1, 2, &c);
65 // Complete object ctor for C delegates.
66 // ITANIUM-LABEL: define linkonce_odr void @_ZN17noninline_nonvirt1CCI1NS_1AEEiO1QPvU17pass_object_size0(
67 // ITANIUM: call void @_ZN17noninline_nonvirt1CCI2NS_1AEEiO1QPvU17pass_object_size0({{.*}}, i32 {{.*}}, %{{.*}}* {{.*}}, i8* {{.*}}, i{{32|64}} {{.*}})
68
69 // MSABI-LABEL: define internal {{.*}} @"\01??0C@noninline_nonvirt@@Q{{AE|EAA}}@H$$Q{{E?}}AUQ@@P{{E?}}AXW4__pass_object_size0@__clang@@@Z"(%{{.*}}, i32{{.*}}, %{{.*}}, i8*{{.*}}, i{{32|64}}{{.*}})
70 // MSABI: call {{.*}} @"\01??0B@noninline_nonvirt@@Q{{AE|EAA}}@H$$Q{{E?}}AUQ@@P{{E?}}AXW4__pass_object_size0@__clang@@@Z"(%{{.*}}, i32{{.*}}, %{{.*}}, i8*{{.*}}, i{{32|64}}{{.*}})
71 }
72
73 namespace noninline_virt {
74 struct A { A(int, Q&&, void *__attribute__((pass_object_size(0)))); int n; };
75 struct B : Z, virtual A { Z z; using A::A; };
76 B b(1, 2, &b);
77 // Complete object ctor forwards to A ctor then constructs Zs.
78 // ITANIUM-LABEL: define linkonce_odr void @_ZN14noninline_virt1BCI1NS_1AEEiO1QPvU17pass_object_size0(
79 // ITANIUM: call void @_ZN14noninline_virt1AC2EiO1QPvU17pass_object_size0({{.*}} %{{.*}}, i32 %{{.*}}, %{{.*}}* {{.*}}, i8* {{.*}}, i{{32|64}} %{{.*}}
80 // ITANIUM: call void @_ZN1ZC2Ev(
81 // ITANIUM: store {{.*}} @_ZTVN14noninline_virt1BE
82 // ITANIUM: call void @_ZN1ZC1Ev(
83
84 // MSABI-LABEL: define internal {{.*}} @"\01??0B@noninline_virt@@Q{{AE|EAA}}@H$$Q{{E?}}AUQ@@P{{E?}}AXW4__pass_object_size0@__clang@@@Z"(%{{.*}}, i32{{.*}}, %{{.*}}, i8*{{.*}}, i{{32|64}}{{.*}}, i32 %{{.*}})
85 // MSABI: %[[COMPLETE:.*]] = icmp ne
86 // MSABI: br i1 %[[COMPLETE]],
87 // MSABI: call {{.*}} @"\01??0A@noninline_virt@@Q{{AE|EAA}}@H$$Q{{E?}}AUQ@@P{{E?}}AXW4__pass_object_size0@__clang@@@Z"(%{{.*}}, i32{{.*}}, %{{.*}}, i8*{{.*}}, i{{32|64}}{{.*}})
88 // MSABI: br
89 // MSABI: call {{.*}} @"\01??0Z@@Q{{AE|EAA}}@XZ"(
90 // MSABI: call {{.*}} @"\01??0Z@@Q{{AE|EAA}}@XZ"(
91
92 struct C : B { using B::B; };
93 C c(1, 2, &c);
94 // Complete object ctor forwards to A ctor, then calls B's base inheriting
95 // constructor, which takes no arguments other than the this pointer and VTT.
96 // ITANIUM_LABEL: define linkonce_odr void @_ZN14noninline_virt1CCI1NS_1AEEiO1QPvU17pass_object_size0(
97 // ITANIUM: call void @_ZN14noninline_virt1AC2EiO1QPvU17pass_object_size0({{.*}} %{{.*}}, i32 %{{.*}}, %{{.*}}* {{.*}}, i8* %{{.*}}, i{{32|64}} %{{.*}})
98 // ITANIUM: call void @_ZN14noninline_virt1BCI2NS_1AEEiO1QPvU17pass_object_size0(%{{.*}}* %{{.*}}, i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @_ZTTN14noninline_virt1CE, i64 0, i64 1))
99 // ITANIUM: store {{.*}} @_ZTVN14noninline_virt1CE
100
101 // C constructor forwards to B constructor and A constructor. We pass the args
102 // to both. FIXME: Can we pass undef here instead, for the base object
103 // constructor call?
104 // MSABI-LABEL: define internal {{.*}} @"\01??0C@noninline_virt@@Q{{AE|EAA}}@H$$Q{{E?}}AUQ@@P{{E?}}AXW4__pass_object_size0@__clang@@@Z"(%{{.*}}, i32{{.*}}, %{{.*}}, i8*{{.*}}, i{{32|64}}{{.*}}, i32 %{{.*}})
105 // MSABI: %[[COMPLETE:.*]] = icmp ne
106 // MSABI: br i1 %[[COMPLETE]],
107 // MSABI: call {{.*}} @"\01??0A@noninline_virt@@Q{{AE|EAA}}@H$$Q{{E?}}AUQ@@P{{E?}}AXW4__pass_object_size0@__clang@@@Z"(%{{.*}}, i32{{.*}}, %{{.*}}, i8*{{.*}}, i{{32|64}}{{.*}})
108 // MSABI: br
109 // MSABI: call {{.*}} @"\01??0B@noninline_virt@@Q{{AE|EAA}}@H$$Q{{E?}}AUQ@@P{{E?}}AXW4__pass_object_size0@__clang@@@Z"(%{{.*}}, i32{{.*}}, %{{.*}}, i8*{{.*}}, i{{32|64}}{{.*}}, i32 0)
110 }
111
112 // For MSABI only, check that inalloca arguments result in inlining.
113 namespace inalloca_nonvirt {
114 struct A { A(Q, int, Q, Q&&); int n; };
115 struct B : Z, A { Z z; using A::A; };
116 B b(1, 2, 3, 4);
117 // No inlining implied for Itanium.
118 // ITANIUM-LABEL: define linkonce_odr void @_ZN16inalloca_nonvirt1BCI1NS_1AEE1QiS1_OS1_(
119 // ITANIUM: call void @_ZN16inalloca_nonvirt1BCI2NS_1AEE1QiS1_OS1_(
120
121 // MSABI-LABEL: define internal void @"\01??__Eb@inalloca_nonvirt@@YAXXZ"(
122
123 // On Win32, the inalloca call can't be forwarded so we force inlining.
124 // WIN32: %[[TMP:.*]] = alloca
125 // WIN32: call i8* @llvm.stacksave()
126 // WIN32: %[[ARGMEM:.*]] = alloca inalloca
127 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"(%{{.*}}* %[[TMP]], i32 4)
128 // WIN32: %[[ARG3:.*]] = getelementptr {{.*}} %[[ARGMEM]]
129 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"({{.*}}* %[[ARG3]], i32 3)
130 // WIN32: %[[ARG1:.*]] = getelementptr {{.*}} %[[ARGMEM]]
131 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"({{.*}}* %[[ARG1]], i32 1)
132 // WIN32: call {{.*}} @"\01??0Z@@QAE@XZ"(
133 // WIN32: %[[ARG2:.*]] = getelementptr {{.*}} %[[ARGMEM]]
134 // WIN32: store i32 2, i32* %[[ARG2]]
135 // WIN32: %[[ARG4:.*]] = getelementptr {{.*}} %[[ARGMEM]]
136 // WIN32: store {{.*}}* %[[TMP]], {{.*}}** %[[ARG4]]
137 // WIN32: call {{.*}} @"\01??0A@inalloca_nonvirt@@QAE@UQ@@H0$$QAU2@@Z"(%{{[^,]*}}, <{{.*}}>* inalloca %[[ARGMEM]])
138 // WIN32: call void @llvm.stackrestore(
139 // WIN32: call {{.*}} @"\01??0Z@@QAE@XZ"(
140 // WIN32: call {{.*}} @"\01??_DQ@@QAE@XZ"(
141
142 // On Win64, the Q arguments would be destroyed in the callee. We don't yet
143 // support that in the non-inlined case, so we force inlining.
144 // WIN64: %[[TMP:.*]] = alloca
145 // WIN64: %[[ARG3:.*]] = alloca
146 // WIN64: %[[ARG1:.*]] = alloca
147 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[TMP]], i32 4)
148 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[ARG3]], i32 3)
149 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[ARG1]], i32 1)
150 // WIN64: call {{.*}} @"\01??0Z@@QEAA@XZ"(
151 // WIN64: call {{.*}} @"\01??0A@inalloca_nonvirt@@QEAA@UQ@@H0$$QEAU2@@Z"(%{{.*}}, %{{.*}}* %[[ARG1]], i32 2, %{{.*}}* %[[ARG3]], %{{.*}} %[[TMP]])
152 // WIN64: call {{.*}} @"\01??0Z@@QEAA@XZ"(
153 // WIN64: call void @"\01??_DQ@@QEAA@XZ"({{.*}}* %[[TMP]])
154
155 struct C : B { using B::B; };
156 C c(1, 2, 3, 4);
157 // MSABI-LABEL: define internal void @"\01??__Ec@inalloca_nonvirt@@YAXXZ"(
158
159 // On Win32, the inalloca call can't be forwarded so we force inlining.
160 // WIN32: %[[TMP:.*]] = alloca
161 // WIN32: call i8* @llvm.stacksave()
162 // WIN32: %[[ARGMEM:.*]] = alloca inalloca
163 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"(%{{.*}}* %[[TMP]], i32 4)
164 // WIN32: %[[ARG3:.*]] = getelementptr {{.*}} %[[ARGMEM]]
165 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"({{.*}}* %[[ARG3]], i32 3)
166 // WIN32: %[[ARG1:.*]] = getelementptr {{.*}} %[[ARGMEM]]
167 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"({{.*}}* %[[ARG1]], i32 1)
168 // WIN32: call {{.*}} @"\01??0Z@@QAE@XZ"(
169 // WIN32: %[[ARG2:.*]] = getelementptr {{.*}} %[[ARGMEM]]
170 // WIN32: store i32 2, i32* %[[ARG2]]
171 // WIN32: %[[ARG4:.*]] = getelementptr {{.*}} %[[ARGMEM]]
172 // WIN32: store {{.*}}* %[[TMP]], {{.*}}** %[[ARG4]]
173 // WIN32: call {{.*}} @"\01??0A@inalloca_nonvirt@@QAE@UQ@@H0$$QAU2@@Z"(%{{[^,]*}}, <{{.*}}>* inalloca %[[ARGMEM]])
174 // WIN32: call void @llvm.stackrestore(
175 // WIN32: call {{.*}} @"\01??0Z@@QAE@XZ"(
176 // WIN32: call {{.*}} @"\01??_DQ@@QAE@XZ"(
177
178 // On Win64, the Q arguments would be destroyed in the callee. We don't yet
179 // support that in the non-inlined case, so we force inlining.
180 // WIN64: %[[TMP:.*]] = alloca
181 // WIN64: %[[ARG3:.*]] = alloca
182 // WIN64: %[[ARG1:.*]] = alloca
183 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[TMP]], i32 4)
184 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[ARG3]], i32 3)
185 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[ARG1]], i32 1)
186 // WIN64: call {{.*}} @"\01??0Z@@QEAA@XZ"(
187 // WIN64: call {{.*}} @"\01??0A@inalloca_nonvirt@@QEAA@UQ@@H0$$QEAU2@@Z"(%{{.*}}, %{{.*}}* %[[ARG1]], i32 2, %{{.*}}* %[[ARG3]], %{{.*}} %[[TMP]])
188 // WIN64: call {{.*}} @"\01??0Z@@QEAA@XZ"(
189 // WIN64: call void @"\01??_DQ@@QEAA@XZ"({{.*}}* %[[TMP]])
190 }
191
192 namespace inalloca_virt {
193 struct A { A(Q, int, Q, Q&&); int n; };
194 struct B : Z, virtual A { Z z; using A::A; };
195 B b(1, 2, 3, 4);
196
197 // MSABI-LABEL: define internal void @"\01??__Eb@inalloca_virt@@YAXXZ"(
198
199 // On Win32, the inalloca call can't be forwarded so we force inlining.
200 // WIN32: %[[TMP:.*]] = alloca
201 // WIN32: call i8* @llvm.stacksave()
202 // WIN32: %[[ARGMEM:.*]] = alloca inalloca
203 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"(%{{.*}}* %[[TMP]], i32 4)
204 // WIN32: %[[ARG3:.*]] = getelementptr {{.*}} %[[ARGMEM]]
205 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"({{.*}}* %[[ARG3]], i32 3)
206 // WIN32: %[[ARG1:.*]] = getelementptr {{.*}} %[[ARGMEM]]
207 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"({{.*}}* %[[ARG1]], i32 1)
208 // FIXME: It's dumb to round-trip this though memory and generate a branch.
209 // WIN32: store i32 1, i32* %[[IS_MOST_DERIVED_ADDR:.*]]
210 // WIN32: %[[IS_MOST_DERIVED:.*]] = load i32, i32* %[[IS_MOST_DERIVED_ADDR]]
211 // WIN32: %[[IS_MOST_DERIVED_i1:.*]] = icmp ne i32 %[[IS_MOST_DERIVED]], 0
212 // WIN32: br i1 %[[IS_MOST_DERIVED_i1]]
213 //
214 // WIN32: store {{.*}} @"\01??_8B@inalloca_virt@@7B@"
215 // WIN32: %[[ARG2:.*]] = getelementptr {{.*}} %[[ARGMEM]]
216 // WIN32: store i32 2, i32* %[[ARG2]]
217 // WIN32: %[[ARG4:.*]] = getelementptr {{.*}} %[[ARGMEM]]
218 // WIN32: store {{.*}}* %[[TMP]], {{.*}}** %[[ARG4]]
219 // WIN32: call {{.*}} @"\01??0A@inalloca_virt@@QAE@UQ@@H0$$QAU2@@Z"(%{{[^,]*}}, <{{.*}}>* inalloca %[[ARGMEM]])
220 // WIN32: call void @llvm.stackrestore(
221 // WIN32: br
222 //
223 // Note that if we jumped directly to here we would fail to stackrestore and
224 // destroy the parameters, but that's not actually possible.
225 // WIN32: call {{.*}} @"\01??0Z@@QAE@XZ"(
226 // WIN32: call {{.*}} @"\01??0Z@@QAE@XZ"(
227 // WIN32: call {{.*}} @"\01??_DQ@@QAE@XZ"(
228
229 // On Win64, the Q arguments would be destroyed in the callee. We don't yet
230 // support that in the non-inlined case, so we force inlining.
231 // WIN64: %[[TMP:.*]] = alloca
232 // WIN64: %[[ARG3:.*]] = alloca
233 // WIN64: %[[ARG1:.*]] = alloca
234 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[TMP]], i32 4)
235 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[ARG3]], i32 3)
236 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[ARG1]], i32 1)
237 // WIN64: br i1
238 // WIN64: call {{.*}} @"\01??0A@inalloca_virt@@QEAA@UQ@@H0$$QEAU2@@Z"(%{{.*}}, %{{.*}}* %[[ARG1]], i32 2, %{{.*}}* %[[ARG3]], %{{.*}} %[[TMP]])
239 // WIN64: br
240 // WIN64: call {{.*}} @"\01??0Z@@QEAA@XZ"(
241 // WIN64: call {{.*}} @"\01??0Z@@QEAA@XZ"(
242 // WIN64: call void @"\01??_DQ@@QEAA@XZ"({{.*}}* %[[TMP]])
243
244 struct C : B { using B::B; };
245 C c(1, 2, 3, 4);
246 // ITANIUM-LABEL: define linkonce_odr void @_ZN13inalloca_virt1CD1Ev(
247
248 // MSABI-LABEL: define internal void @"\01??__Ec@inalloca_virt@@YAXXZ"(
249
250 // On Win32, the inalloca call can't be forwarded so we force inlining.
251 // WIN32: %[[TMP:.*]] = alloca
252 // WIN32: call i8* @llvm.stacksave()
253 // WIN32: %[[ARGMEM:.*]] = alloca inalloca
254 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"(%{{.*}}* %[[TMP]], i32 4)
255 // WIN32: %[[ARG3:.*]] = getelementptr {{.*}} %[[ARGMEM]]
256 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"({{.*}}* %[[ARG3]], i32 3)
257 // WIN32: %[[ARG1:.*]] = getelementptr {{.*}} %[[ARGMEM]]
258 // WIN32: call {{.*}} @"\01??0Q@@QAE@H@Z"({{.*}}* %[[ARG1]], i32 1)
259 // WIN32: store i32 1, i32* %[[IS_MOST_DERIVED_ADDR:.*]]
260 // WIN32: %[[IS_MOST_DERIVED:.*]] = load i32, i32* %[[IS_MOST_DERIVED_ADDR]]
261 // WIN32: %[[IS_MOST_DERIVED_i1:.*]] = icmp ne i32 %[[IS_MOST_DERIVED]], 0
262 // WIN32: br i1 %[[IS_MOST_DERIVED_i1]]
263 //
264 // WIN32: store {{.*}} @"\01??_8C@inalloca_virt@@7B@"
265 // WIN32: %[[ARG2:.*]] = getelementptr {{.*}} %[[ARGMEM]]
266 // WIN32: store i32 2, i32* %[[ARG2]]
267 // WIN32: %[[ARG4:.*]] = getelementptr {{.*}} %[[ARGMEM]]
268 // WIN32: store {{.*}}* %[[TMP]], {{.*}}** %[[ARG4]]
269 // WIN32: call {{.*}} @"\01??0A@inalloca_virt@@QAE@UQ@@H0$$QAU2@@Z"(%{{[^,]*}}, <{{.*}}>* inalloca %[[ARGMEM]])
270 // WIN32: call void @llvm.stackrestore(
271 // WIN32: br
272 //
273 // WIN32: store i32 0, i32* %[[IS_MOST_DERIVED_ADDR:.*]]
274 // WIN32: %[[IS_MOST_DERIVED:.*]] = load i32, i32* %[[IS_MOST_DERIVED_ADDR]]
275 // WIN32: %[[IS_MOST_DERIVED_i1:.*]] = icmp ne i32 %[[IS_MOST_DERIVED]], 0
276 // WIN32: br i1 %[[IS_MOST_DERIVED_i1]]
277 //
278 // Note: this block is unreachable.
279 // WIN32: store {{.*}} @"\01??_8B@inalloca_virt@@7B@"
280 // WIN32: br
281 //
282 // WIN32: call {{.*}} @"\01??0Z@@QAE@XZ"(
283 // WIN32: call {{.*}} @"\01??0Z@@QAE@XZ"(
284 // WIN32: call {{.*}} @"\01??_DQ@@QAE@XZ"(
285
286 // On Win64, the Q arguments would be destroyed in the callee. We don't yet
287 // support that in the non-inlined case, so we force inlining.
288 // WIN64: %[[TMP:.*]] = alloca
289 // WIN64: %[[ARG3:.*]] = alloca
290 // WIN64: %[[ARG1:.*]] = alloca
291 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[TMP]], i32 4)
292 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[ARG3]], i32 3)
293 // WIN64: call {{.*}} @"\01??0Q@@QEAA@H@Z"({{.*}}* %[[ARG1]], i32 1)
294 // WIN64: br i1
295 // WIN64: store {{.*}} @"\01??_8C@inalloca_virt@@7B@"
296 // WIN64: call {{.*}} @"\01??0A@inalloca_virt@@QEAA@UQ@@H0$$QEAU2@@Z"(%{{.*}}, %{{.*}}* %[[ARG1]], i32 2, %{{.*}}* %[[ARG3]], %{{.*}} %[[TMP]])
297 // WIN64: br
298 // WIN64: br i1
299 // (Unreachable block)
300 // WIN64: store {{.*}} @"\01??_8B@inalloca_virt@@7B@"
301 // WIN64: br
302 // WIN64: call {{.*}} @"\01??0Z@@QEAA@XZ"(
303 // WIN64: call {{.*}} @"\01??0Z@@QEAA@XZ"(
304 // WIN64: call void @"\01??_DQ@@QEAA@XZ"({{.*}}* %[[TMP]])
305 }
306
307 namespace inline_nonvirt {
308 struct A { A(Q, int, Q, Q&&, ...); int n; };
309 struct B : Z, A { Z z; using A::A; };
310 B b(1, 2, 3, 4, 5, 6);
311 // Inlined all the way down to the A ctor.
312 // ITANIUM-LABEL: define {{.*}} @__cxx_global_var_init
313 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 1)
314 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 3)
315 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 4)
316 // ITANIUM: %[[Z_BASE:.*]] = bitcast %{{.*}}* %[[THIS:.*]] to
317 // ITANIUM: call void @_ZN1ZC2Ev(
318 // ITANIUM: %[[B_CAST:.*]] = bitcast {{.*}} %[[THIS]]
319 // ITANIUM: %[[A_CAST:.*]] = getelementptr {{.*}} %[[B_CAST]], i{{32|64}} 4
320 // ITANIUM: %[[A:.*]] = bitcast {{.*}} %[[A_CAST]]
321 // ITANIUM: call void ({{.*}}, ...) @_ZN14inline_nonvirt1AC2E1QiS1_OS1_z(%{{.*}}* %[[A]], {{.*}}, i32 2, {{.*}}, {{.*}}, i32 5, i32 6)
322 // ITANIUM: %[[Z_MEMBER:.*]] = getelementptr {{.*}} %[[THIS]], i32 0, i32 2
323 // ITANIUM: call void @_ZN1ZC1Ev({{.*}} %[[Z_MEMBER]])
324 // ITANIUM: call void @_ZN1QD1Ev(
325 // ITANIUM: call void @_ZN1QD1Ev(
326 // ITANIUM: call void @_ZN1QD1Ev(
327
328 struct C : B { using B::B; };
329 C c(1, 2, 3, 4, 5, 6);
330 // Inlined all the way down to the A ctor.
331 // ITANIUM-LABEL: define {{.*}} @__cxx_global_var_init
332 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 1)
333 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 3)
334 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 4)
335 // ITANIUM: %[[Z_BASE:.*]] = bitcast %{{.*}}* %[[THIS:.*]] to
336 // ITANIUM: call void @_ZN1ZC2Ev(
337 // ITANIUM: %[[B_CAST:.*]] = bitcast {{.*}} %[[THIS]]
338 // ITANIUM: %[[A_CAST:.*]] = getelementptr {{.*}} %[[B_CAST]], i{{32|64}} 4
339 // ITANIUM: %[[A:.*]] = bitcast {{.*}} %[[A_CAST]]
340 // ITANIUM: call void ({{.*}}, ...) @_ZN14inline_nonvirt1AC2E1QiS1_OS1_z(%{{.*}}* %[[A]], {{.*}}, i32 2, {{.*}}, {{.*}}, i32 5, i32 6)
341 // ITANIUM: %[[Z_MEMBER:.*]] = getelementptr {{.*}} %{{.*}}, i32 0, i32 2
342 // ITANIUM: call void @_ZN1ZC1Ev({{.*}} %[[Z_MEMBER]])
343 // ITANIUM: call void @_ZN1QD1Ev(
344 // ITANIUM: call void @_ZN1QD1Ev(
345 // ITANIUM: call void @_ZN1QD1Ev(
346 }
347
348 namespace inline_virt {
349 struct A { A(Q, int, Q, Q&&, ...); int n; };
350 struct B : Z, virtual A { Z z; using A::A; };
351 B b(1, 2, 3, 4, 5, 6);
352 // Inlined all the way down to the A ctor.
353 // ITANIUM-LABEL: define {{.*}} @__cxx_global_var_init
354 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 1)
355 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 3)
356 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 4)
357 // ITANIUM: %[[B_CAST:.*]] = bitcast {{.*}} %[[THIS:.*]]
358 // ITANIUM: %[[A_CAST:.*]] = getelementptr {{.*}} %[[B_CAST]], i{{32|64}} {{12|16}}
359 // ITANIUM: %[[A:.*]] = bitcast {{.*}} %[[A_CAST]]
360 // ITANIUM: call void ({{.*}}, ...) @_ZN11inline_virt1AC2E1QiS1_OS1_z(%{{.*}}* %[[A]], {{.*}}, i32 2, {{.*}}, {{.*}}, i32 5, i32 6)
361 // ITANIUM: call void @_ZN1ZC2Ev(
362 // ITANIUM: call void @_ZN1ZC1Ev(
363 // ITANIUM: call void @_ZN1QD1Ev(
364 // ITANIUM: call void @_ZN1QD1Ev(
365 // ITANIUM: call void @_ZN1QD1Ev(
366
367 struct C : B { using B::B; };
368 C c(1, 2, 3, 4, 5, 6);
369 // Inlined all the way down to the A ctor, except that we can just call the
370 // B base inheriting constructor to construct that portion (it doesn't need
371 // the forwarded arguments).
372 // ITANIUM-LABEL: define {{.*}} @__cxx_global_var_init
373 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 1)
374 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 3)
375 // ITANIUM: call void @_ZN1QC1Ei({{.*}}, i32 4)
376 // ITANIUM: %[[B_CAST:.*]] = bitcast {{.*}} %[[THIS:.*]]
377 // ITANIUM: %[[A_CAST:.*]] = getelementptr {{.*}} %[[B_CAST]], i{{32|64}} {{12|16}}
378 // ITANIUM: %[[A:.*]] = bitcast {{.*}} %[[A_CAST]]
379 // ITANIUM: call void ({{.*}}, ...) @_ZN11inline_virt1AC2E1QiS1_OS1_z(%{{.*}}* %[[A]], {{.*}}, i32 2, {{.*}}, {{.*}}, i32 5, i32 6)
380 // ITANIUM: call void @_ZN11inline_virt1BCI2NS_1AEE1QiS1_OS1_z({{[^,]*}}, i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @_ZTTN11inline_virt1CE, i64 0, i64 1))
381 // ITANIUM: store {{.*}} @_ZTVN11inline_virt1CE
382 // ITANIUM: call void @_ZN1QD1Ev(
383 // ITANIUM: call void @_ZN1QD1Ev(
384 // ITANIUM: call void @_ZN1QD1Ev(
385
386 // B base object inheriting constructor does not get passed arguments.
387 // ITANIUM-LABEL: define linkonce_odr void @_ZN11inline_virt1BCI2NS_1AEE1QiS1_OS1_z(
388 // ITANIUM-NOT: call
389 // ITANIUM: call void @_ZN1ZC2Ev(
390 // ITANIUM-NOT: call
391 // VTT -> vtable
392 // ITANIUM: store
393 // ITANIUM-NOT: call
394 // ITANIUM: call void @_ZN1ZC1Ev(
395 // ITANIUM-NOT: call
396 // ITANIUM: }
397 }
398
399 // ITANIUM-LABEL: define linkonce_odr void @_ZN1BCI21AEi(
400 // ITANIUM: call void @_ZN1AC2Ei(
401
402 // ITANIUM-LABEL: define linkonce_odr void @_ZN1DCI21CIiEET_(
403 // ITANIUM: call void @_ZN1CC2IiEET_(
404
405 // ITANIUM-LABEL: define linkonce_odr void @_ZN17noninline_nonvirt1BCI2NS_1AEEiO1QPvU17pass_object_size0(
406 // ITANIUM: call void @_ZN1ZC2Ev(
407 // ITANIUM: call void @_ZN17noninline_nonvirt1AC2EiO1QPvU17pass_object_size0(
408
409 // ITANIUM-LABEL: define linkonce_odr void @_ZN17noninline_nonvirt1CCI2NS_1AEEiO1QPvU17pass_object_size0(
410 // ITANIUM: call void @_ZN17noninline_nonvirt1BCI2NS_1AEEiO1QPvU17pass_object_size0(
411