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