annotate clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp @ 173:0572611fdcc8 llvm10 llvm12

reorgnization done
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 11:55:54 +0900
parents 1d019706d866
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=i386-pc-linux | FileCheck -check-prefix LINUX %s
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WIN32 %s
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=thumb-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WOA %s
anatofuz
parents:
diff changeset
4 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WIN64 %s
anatofuz
parents:
diff changeset
5 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=aarch64-windows-msvc -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WOA64 %s
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 struct Empty {};
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 struct EmptyWithCtor {
anatofuz
parents:
diff changeset
10 EmptyWithCtor() {}
anatofuz
parents:
diff changeset
11 };
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 struct Small {
anatofuz
parents:
diff changeset
14 int x;
anatofuz
parents:
diff changeset
15 };
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 // This is a C++11 trivial and standard-layout struct but not a C++03 POD.
anatofuz
parents:
diff changeset
18 struct SmallCpp11NotCpp03Pod : Empty {
anatofuz
parents:
diff changeset
19 int x;
anatofuz
parents:
diff changeset
20 };
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 struct SmallWithCtor {
anatofuz
parents:
diff changeset
23 SmallWithCtor() {}
anatofuz
parents:
diff changeset
24 int x;
anatofuz
parents:
diff changeset
25 };
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 struct Multibyte {
anatofuz
parents:
diff changeset
28 char a, b, c, d;
anatofuz
parents:
diff changeset
29 };
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 struct Packed {
anatofuz
parents:
diff changeset
32 short a;
anatofuz
parents:
diff changeset
33 int b;
anatofuz
parents:
diff changeset
34 short c;
anatofuz
parents:
diff changeset
35 };
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 struct SmallWithDtor {
anatofuz
parents:
diff changeset
38 SmallWithDtor();
anatofuz
parents:
diff changeset
39 ~SmallWithDtor();
anatofuz
parents:
diff changeset
40 int x;
anatofuz
parents:
diff changeset
41 };
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 struct SmallWithVftable {
anatofuz
parents:
diff changeset
44 int x;
anatofuz
parents:
diff changeset
45 virtual void foo();
anatofuz
parents:
diff changeset
46 };
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 struct Medium {
anatofuz
parents:
diff changeset
49 int x, y;
anatofuz
parents:
diff changeset
50 };
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 struct MediumWithCopyCtor {
anatofuz
parents:
diff changeset
53 MediumWithCopyCtor();
anatofuz
parents:
diff changeset
54 MediumWithCopyCtor(const struct MediumWithCopyCtor &);
anatofuz
parents:
diff changeset
55 int x, y;
anatofuz
parents:
diff changeset
56 };
anatofuz
parents:
diff changeset
57
anatofuz
parents:
diff changeset
58 struct Big {
anatofuz
parents:
diff changeset
59 int a, b, c, d, e, f;
anatofuz
parents:
diff changeset
60 };
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 struct BigWithDtor {
anatofuz
parents:
diff changeset
63 BigWithDtor();
anatofuz
parents:
diff changeset
64 ~BigWithDtor();
anatofuz
parents:
diff changeset
65 int a, b, c, d, e, f;
anatofuz
parents:
diff changeset
66 };
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 struct BaseNoByval : Small {
anatofuz
parents:
diff changeset
69 int bb;
anatofuz
parents:
diff changeset
70 };
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 struct SmallWithPrivate {
anatofuz
parents:
diff changeset
73 private:
anatofuz
parents:
diff changeset
74 int i;
anatofuz
parents:
diff changeset
75 };
anatofuz
parents:
diff changeset
76
anatofuz
parents:
diff changeset
77 // WIN32: declare dso_local void @"{{.*take_bools_and_chars.*}}"
anatofuz
parents:
diff changeset
78 // WIN32: (<{ i8, [3 x i8], i8, [3 x i8], %struct.SmallWithDtor,
anatofuz
parents:
diff changeset
79 // WIN32: i8, [3 x i8], i8, [3 x i8], i32, i8, [3 x i8] }>* inalloca)
anatofuz
parents:
diff changeset
80 void take_bools_and_chars(char a, char b, SmallWithDtor c, char d, bool e, int f, bool g);
anatofuz
parents:
diff changeset
81 void call_bools_and_chars() {
anatofuz
parents:
diff changeset
82 take_bools_and_chars('A', 'B', SmallWithDtor(), 'D', true, 13, false);
anatofuz
parents:
diff changeset
83 }
anatofuz
parents:
diff changeset
84
anatofuz
parents:
diff changeset
85 // Returning structs that fit into a register.
anatofuz
parents:
diff changeset
86 Small small_return() { return Small(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
87 // LINUX-LABEL: define void @_Z12small_returnv(%struct.Small* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
88 // WIN32: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
anatofuz
parents:
diff changeset
89 // WIN64: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 Medium medium_return() { return Medium(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
92 // LINUX-LABEL: define void @_Z13medium_returnv(%struct.Medium* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
93 // WIN32: define dso_local i64 @"?medium_return@@YA?AUMedium@@XZ"()
anatofuz
parents:
diff changeset
94 // WIN64: define dso_local i64 @"?medium_return@@YA?AUMedium@@XZ"()
anatofuz
parents:
diff changeset
95
anatofuz
parents:
diff changeset
96 // Returning structs that fit into a register but are not POD.
anatofuz
parents:
diff changeset
97 SmallCpp11NotCpp03Pod small_non_pod_return() { return SmallCpp11NotCpp03Pod(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
98 // LINUX-LABEL: define void @_Z20small_non_pod_returnv(%struct.SmallCpp11NotCpp03Pod* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
99 // WIN32: define dso_local void @"?small_non_pod_return@@YA?AUSmallCpp11NotCpp03Pod@@XZ"(%struct.SmallCpp11NotCpp03Pod* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
100 // WIN64: define dso_local void @"?small_non_pod_return@@YA?AUSmallCpp11NotCpp03Pod@@XZ"(%struct.SmallCpp11NotCpp03Pod* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
101
anatofuz
parents:
diff changeset
102 SmallWithCtor small_with_ctor_return() { return SmallWithCtor(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
103 // LINUX-LABEL: define void @_Z22small_with_ctor_returnv(%struct.SmallWithCtor* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
104 // WIN32: define dso_local void @"?small_with_ctor_return@@YA?AUSmallWithCtor@@XZ"(%struct.SmallWithCtor* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
105 // WIN64: define dso_local void @"?small_with_ctor_return@@YA?AUSmallWithCtor@@XZ"(%struct.SmallWithCtor* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
106 // FIXME: The 'sret' mark here doesn't seem to be enough to convince LLVM to
anatofuz
parents:
diff changeset
107 // preserve the hidden sret pointer in R0 across the function.
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
108 // WOA: define dso_local arm_aapcs_vfpcc void @"?small_with_ctor_return@@YA?AUSmallWithCtor@@XZ"(%struct.SmallWithCtor* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
109
anatofuz
parents:
diff changeset
110 SmallWithVftable small_with_vftable_return() { return SmallWithVftable(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
111 // LINUX-LABEL: define void @_Z25small_with_vftable_returnv(%struct.SmallWithVftable* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
112 // WIN32: define dso_local void @"?small_with_vftable_return@@YA?AUSmallWithVftable@@XZ"(%struct.SmallWithVftable* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
113 // WIN64: define dso_local void @"?small_with_vftable_return@@YA?AUSmallWithVftable@@XZ"(%struct.SmallWithVftable* noalias sret align 8 %agg.result)
150
anatofuz
parents:
diff changeset
114
anatofuz
parents:
diff changeset
115 MediumWithCopyCtor medium_with_copy_ctor_return() { return MediumWithCopyCtor(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
116 // LINUX-LABEL: define void @_Z28medium_with_copy_ctor_returnv(%struct.MediumWithCopyCtor* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
117 // WIN32: define dso_local void @"?medium_with_copy_ctor_return@@YA?AUMediumWithCopyCtor@@XZ"(%struct.MediumWithCopyCtor* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
118 // WIN64: define dso_local void @"?medium_with_copy_ctor_return@@YA?AUMediumWithCopyCtor@@XZ"(%struct.MediumWithCopyCtor* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
119 // WOA: define dso_local arm_aapcs_vfpcc void @"?medium_with_copy_ctor_return@@YA?AUMediumWithCopyCtor@@XZ"(%struct.MediumWithCopyCtor* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
120
anatofuz
parents:
diff changeset
121 // Returning a large struct that doesn't fit into a register.
anatofuz
parents:
diff changeset
122 Big big_return() { return Big(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
123 // LINUX-LABEL: define void @_Z10big_returnv(%struct.Big* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
124 // WIN32: define dso_local void @"?big_return@@YA?AUBig@@XZ"(%struct.Big* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
125 // WIN64: define dso_local void @"?big_return@@YA?AUBig@@XZ"(%struct.Big* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
126
anatofuz
parents:
diff changeset
127
anatofuz
parents:
diff changeset
128 void small_arg(Small s) {}
anatofuz
parents:
diff changeset
129 // LINUX-LABEL: define void @_Z9small_arg5Small(i32 %s.0)
anatofuz
parents:
diff changeset
130 // WIN32: define dso_local void @"?small_arg@@YAXUSmall@@@Z"(i32 %s.0)
anatofuz
parents:
diff changeset
131 // WIN64: define dso_local void @"?small_arg@@YAXUSmall@@@Z"(i32 %s.coerce)
anatofuz
parents:
diff changeset
132 // WOA: define dso_local arm_aapcs_vfpcc void @"?small_arg@@YAXUSmall@@@Z"([1 x i32] %s.coerce)
anatofuz
parents:
diff changeset
133
anatofuz
parents:
diff changeset
134 void medium_arg(Medium s) {}
anatofuz
parents:
diff changeset
135 // LINUX-LABEL: define void @_Z10medium_arg6Medium(i32 %s.0, i32 %s.1)
anatofuz
parents:
diff changeset
136 // WIN32: define dso_local void @"?medium_arg@@YAXUMedium@@@Z"(i32 %s.0, i32 %s.1)
anatofuz
parents:
diff changeset
137 // WIN64: define dso_local void @"?medium_arg@@YAXUMedium@@@Z"(i64 %s.coerce)
anatofuz
parents:
diff changeset
138 // WOA: define dso_local arm_aapcs_vfpcc void @"?medium_arg@@YAXUMedium@@@Z"([2 x i32] %s.coerce)
anatofuz
parents:
diff changeset
139
anatofuz
parents:
diff changeset
140 void base_no_byval_arg(BaseNoByval s) {}
anatofuz
parents:
diff changeset
141 // LINUX-LABEL: define void @_Z17base_no_byval_arg11BaseNoByval(%struct.BaseNoByval* byval(%struct.BaseNoByval) align 4 %s)
anatofuz
parents:
diff changeset
142 // WIN32: define dso_local void @"?base_no_byval_arg@@YAXUBaseNoByval@@@Z"(i32 %s.0, i32 %s.1)
anatofuz
parents:
diff changeset
143 // WIN64: define dso_local void @"?base_no_byval_arg@@YAXUBaseNoByval@@@Z"(i64 %s.coerce)
anatofuz
parents:
diff changeset
144 // WOA: define dso_local arm_aapcs_vfpcc void @"?base_no_byval_arg@@YAXUBaseNoByval@@@Z"([2 x i32] %s.coerce)
anatofuz
parents:
diff changeset
145
anatofuz
parents:
diff changeset
146 void small_arg_with_ctor(SmallWithCtor s) {}
anatofuz
parents:
diff changeset
147 // LINUX-LABEL: define void @_Z19small_arg_with_ctor13SmallWithCtor(%struct.SmallWithCtor* byval(%struct.SmallWithCtor) align 4 %s)
anatofuz
parents:
diff changeset
148 // WIN32: define dso_local void @"?small_arg_with_ctor@@YAXUSmallWithCtor@@@Z"(i32 %s.0)
anatofuz
parents:
diff changeset
149 // WIN64: define dso_local void @"?small_arg_with_ctor@@YAXUSmallWithCtor@@@Z"(i32 %s.coerce)
anatofuz
parents:
diff changeset
150 // WOA: define dso_local arm_aapcs_vfpcc void @"?small_arg_with_ctor@@YAXUSmallWithCtor@@@Z"([1 x i32] %s.coerce)
anatofuz
parents:
diff changeset
151
anatofuz
parents:
diff changeset
152 // FIXME: We could coerce to a series of i32s here if we wanted to.
anatofuz
parents:
diff changeset
153 void multibyte_arg(Multibyte s) {}
anatofuz
parents:
diff changeset
154 // LINUX-LABEL: define void @_Z13multibyte_arg9Multibyte(%struct.Multibyte* byval(%struct.Multibyte) align 4 %s)
anatofuz
parents:
diff changeset
155 // WIN32: define dso_local void @"?multibyte_arg@@YAXUMultibyte@@@Z"(%struct.Multibyte* byval(%struct.Multibyte) align 4 %s)
anatofuz
parents:
diff changeset
156 // WIN64: define dso_local void @"?multibyte_arg@@YAXUMultibyte@@@Z"(i32 %s.coerce)
anatofuz
parents:
diff changeset
157 // WOA: define dso_local arm_aapcs_vfpcc void @"?multibyte_arg@@YAXUMultibyte@@@Z"([1 x i32] %s.coerce)
anatofuz
parents:
diff changeset
158
anatofuz
parents:
diff changeset
159 void packed_arg(Packed s) {}
anatofuz
parents:
diff changeset
160 // LINUX-LABEL: define void @_Z10packed_arg6Packed(%struct.Packed* byval(%struct.Packed) align 4 %s)
anatofuz
parents:
diff changeset
161 // WIN32: define dso_local void @"?packed_arg@@YAXUPacked@@@Z"(%struct.Packed* byval(%struct.Packed) align 4 %s)
anatofuz
parents:
diff changeset
162 // WIN64: define dso_local void @"?packed_arg@@YAXUPacked@@@Z"(%struct.Packed* %s)
anatofuz
parents:
diff changeset
163
anatofuz
parents:
diff changeset
164 // Test that dtors are invoked in the callee.
anatofuz
parents:
diff changeset
165 void small_arg_with_dtor(SmallWithDtor s) {}
anatofuz
parents:
diff changeset
166 // WIN32: define dso_local void @"?small_arg_with_dtor@@YAXUSmallWithDtor@@@Z"(<{ %struct.SmallWithDtor }>* inalloca %0) {{.*}} {
anatofuz
parents:
diff changeset
167 // WIN32: call x86_thiscallcc void @"??1SmallWithDtor@@QAE@XZ"
anatofuz
parents:
diff changeset
168 // WIN32: }
anatofuz
parents:
diff changeset
169 // WIN64: define dso_local void @"?small_arg_with_dtor@@YAXUSmallWithDtor@@@Z"(i32 %s.coerce) {{.*}} {
anatofuz
parents:
diff changeset
170 // WIN64: call void @"??1SmallWithDtor@@QEAA@XZ"
anatofuz
parents:
diff changeset
171 // WIN64: }
anatofuz
parents:
diff changeset
172 // WOA64: define dso_local void @"?small_arg_with_dtor@@YAXUSmallWithDtor@@@Z"(i64 %s.coerce) {{.*}} {
anatofuz
parents:
diff changeset
173 // WOA64: call void @"??1SmallWithDtor@@QEAA@XZ"(%struct.SmallWithDtor* %s)
anatofuz
parents:
diff changeset
174 // WOA64: }
anatofuz
parents:
diff changeset
175
anatofuz
parents:
diff changeset
176 // FIXME: MSVC incompatible!
anatofuz
parents:
diff changeset
177 // WOA: define dso_local arm_aapcs_vfpcc void @"?small_arg_with_dtor@@YAXUSmallWithDtor@@@Z"(%struct.SmallWithDtor* %s) {{.*}} {
anatofuz
parents:
diff changeset
178 // WOA: call arm_aapcs_vfpcc void @"??1SmallWithDtor@@QAA@XZ"(%struct.SmallWithDtor* %s)
anatofuz
parents:
diff changeset
179 // WOA: }
anatofuz
parents:
diff changeset
180
anatofuz
parents:
diff changeset
181
anatofuz
parents:
diff changeset
182 // Test that the eligible non-aggregate is passed directly, but returned
anatofuz
parents:
diff changeset
183 // indirectly on ARM64 Windows.
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
184 // WOA64: define dso_local void @"?small_arg_with_private_member@@YA?AUSmallWithPrivate@@U1@@Z"(%struct.SmallWithPrivate* inreg noalias sret align 4 %agg.result, i64 %s.coerce) {{.*}} {
150
anatofuz
parents:
diff changeset
185 SmallWithPrivate small_arg_with_private_member(SmallWithPrivate s) { return s; }
anatofuz
parents:
diff changeset
186
anatofuz
parents:
diff changeset
187 void call_small_arg_with_dtor() {
anatofuz
parents:
diff changeset
188 small_arg_with_dtor(SmallWithDtor());
anatofuz
parents:
diff changeset
189 }
anatofuz
parents:
diff changeset
190 // WIN64-LABEL: define dso_local void @"?call_small_arg_with_dtor@@YAXXZ"()
anatofuz
parents:
diff changeset
191 // WIN64: call %struct.SmallWithDtor* @"??0SmallWithDtor@@QEAA@XZ"
anatofuz
parents:
diff changeset
192 // WIN64: call void @"?small_arg_with_dtor@@YAXUSmallWithDtor@@@Z"(i32 %{{.*}})
anatofuz
parents:
diff changeset
193 // WIN64: ret void
anatofuz
parents:
diff changeset
194
anatofuz
parents:
diff changeset
195 // Test that references aren't destroyed in the callee.
anatofuz
parents:
diff changeset
196 void ref_small_arg_with_dtor(const SmallWithDtor &s) { }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
197 // WIN32: define dso_local void @"?ref_small_arg_with_dtor@@YAXABUSmallWithDtor@@@Z"(%struct.SmallWithDtor* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %s) {{.*}} {
150
anatofuz
parents:
diff changeset
198 // WIN32-NOT: call x86_thiscallcc void @"??1SmallWithDtor@@QAE@XZ"
anatofuz
parents:
diff changeset
199 // WIN32: }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
200 // WIN64-LABEL: define dso_local void @"?ref_small_arg_with_dtor@@YAXAEBUSmallWithDtor@@@Z"(%struct.SmallWithDtor* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %s)
150
anatofuz
parents:
diff changeset
201
anatofuz
parents:
diff changeset
202 void big_arg_with_dtor(BigWithDtor s) {}
anatofuz
parents:
diff changeset
203 // WIN64-LABEL: define dso_local void @"?big_arg_with_dtor@@YAXUBigWithDtor@@@Z"(%struct.BigWithDtor* %s)
anatofuz
parents:
diff changeset
204 // WIN64: call void @"??1BigWithDtor@@QEAA@XZ"
anatofuz
parents:
diff changeset
205 // WIN64: }
anatofuz
parents:
diff changeset
206
anatofuz
parents:
diff changeset
207 void call_big_arg_with_dtor() {
anatofuz
parents:
diff changeset
208 big_arg_with_dtor(BigWithDtor());
anatofuz
parents:
diff changeset
209 }
anatofuz
parents:
diff changeset
210 // We can elide the copy of the temporary in the caller, because this object is
anatofuz
parents:
diff changeset
211 // larger than 8 bytes and is passed indirectly.
anatofuz
parents:
diff changeset
212 // WIN64-LABEL: define dso_local void @"?call_big_arg_with_dtor@@YAXXZ"()
anatofuz
parents:
diff changeset
213 // WIN64: call %struct.BigWithDtor* @"??0BigWithDtor@@QEAA@XZ"
anatofuz
parents:
diff changeset
214 // WIN64: call void @"?big_arg_with_dtor@@YAXUBigWithDtor@@@Z"(%struct.BigWithDtor* %{{.*}})
anatofuz
parents:
diff changeset
215 // WIN64-NOT: call void @"??1BigWithDtor@@QEAA@XZ"
anatofuz
parents:
diff changeset
216 // WIN64: ret void
anatofuz
parents:
diff changeset
217
anatofuz
parents:
diff changeset
218 // Test that temporaries passed by reference are destroyed in the caller.
anatofuz
parents:
diff changeset
219 void temporary_ref_with_dtor() {
anatofuz
parents:
diff changeset
220 ref_small_arg_with_dtor(SmallWithDtor());
anatofuz
parents:
diff changeset
221 }
anatofuz
parents:
diff changeset
222 // WIN32: define dso_local void @"?temporary_ref_with_dtor@@YAXXZ"() {{.*}} {
anatofuz
parents:
diff changeset
223 // WIN32: call x86_thiscallcc %struct.SmallWithDtor* @"??0SmallWithDtor@@QAE@XZ"
anatofuz
parents:
diff changeset
224 // WIN32: call void @"?ref_small_arg_with_dtor@@YAXABUSmallWithDtor@@@Z"
anatofuz
parents:
diff changeset
225 // WIN32: call x86_thiscallcc void @"??1SmallWithDtor@@QAE@XZ"
anatofuz
parents:
diff changeset
226 // WIN32: }
anatofuz
parents:
diff changeset
227
anatofuz
parents:
diff changeset
228 void takes_two_by_val_with_dtor(SmallWithDtor a, SmallWithDtor b);
anatofuz
parents:
diff changeset
229 void eh_cleanup_arg_with_dtor() {
anatofuz
parents:
diff changeset
230 takes_two_by_val_with_dtor(SmallWithDtor(), SmallWithDtor());
anatofuz
parents:
diff changeset
231 }
anatofuz
parents:
diff changeset
232 // When exceptions are off, we don't have any cleanups. See
anatofuz
parents:
diff changeset
233 // microsoft-abi-exceptions.cpp for these cleanups.
anatofuz
parents:
diff changeset
234 // WIN32: define dso_local void @"?eh_cleanup_arg_with_dtor@@YAXXZ"() {{.*}} {
anatofuz
parents:
diff changeset
235 // WIN32: call x86_thiscallcc %struct.SmallWithDtor* @"??0SmallWithDtor@@QAE@XZ"
anatofuz
parents:
diff changeset
236 // WIN32: call x86_thiscallcc %struct.SmallWithDtor* @"??0SmallWithDtor@@QAE@XZ"
anatofuz
parents:
diff changeset
237 // WIN32: call void @"?takes_two_by_val_with_dtor@@YAXUSmallWithDtor@@0@Z"
anatofuz
parents:
diff changeset
238 // WIN32-NOT: call x86_thiscallcc void @"??1SmallWithDtor@@QAE@XZ"
anatofuz
parents:
diff changeset
239 // WIN32: }
anatofuz
parents:
diff changeset
240
anatofuz
parents:
diff changeset
241 void small_arg_with_vftable(SmallWithVftable s) {}
anatofuz
parents:
diff changeset
242 // LINUX-LABEL: define void @_Z22small_arg_with_vftable16SmallWithVftable(%struct.SmallWithVftable* %s)
anatofuz
parents:
diff changeset
243 // WIN32: define dso_local void @"?small_arg_with_vftable@@YAXUSmallWithVftable@@@Z"(<{ %struct.SmallWithVftable }>* inalloca %0)
anatofuz
parents:
diff changeset
244 // WIN64: define dso_local void @"?small_arg_with_vftable@@YAXUSmallWithVftable@@@Z"(%struct.SmallWithVftable* %s)
anatofuz
parents:
diff changeset
245 // WOA64: define dso_local void @"?small_arg_with_vftable@@YAXUSmallWithVftable@@@Z"(%struct.SmallWithVftable* %s)
anatofuz
parents:
diff changeset
246
anatofuz
parents:
diff changeset
247 void medium_arg_with_copy_ctor(MediumWithCopyCtor s) {}
anatofuz
parents:
diff changeset
248 // LINUX-LABEL: define void @_Z25medium_arg_with_copy_ctor18MediumWithCopyCtor(%struct.MediumWithCopyCtor* %s)
anatofuz
parents:
diff changeset
249 // WIN32: define dso_local void @"?medium_arg_with_copy_ctor@@YAXUMediumWithCopyCtor@@@Z"(<{ %struct.MediumWithCopyCtor }>* inalloca %0)
anatofuz
parents:
diff changeset
250 // WIN64: define dso_local void @"?medium_arg_with_copy_ctor@@YAXUMediumWithCopyCtor@@@Z"(%struct.MediumWithCopyCtor* %s)
anatofuz
parents:
diff changeset
251 // WOA: define dso_local arm_aapcs_vfpcc void @"?medium_arg_with_copy_ctor@@YAXUMediumWithCopyCtor@@@Z"(%struct.MediumWithCopyCtor* %s)
anatofuz
parents:
diff changeset
252 // WOA64: define dso_local void @"?medium_arg_with_copy_ctor@@YAXUMediumWithCopyCtor@@@Z"(%struct.MediumWithCopyCtor* %s)
anatofuz
parents:
diff changeset
253
anatofuz
parents:
diff changeset
254 void big_arg(Big s) {}
anatofuz
parents:
diff changeset
255 // LINUX-LABEL: define void @_Z7big_arg3Big(%struct.Big* byval(%struct.Big) align 4 %s)
anatofuz
parents:
diff changeset
256 // WIN32: define dso_local void @"?big_arg@@YAXUBig@@@Z"(%struct.Big* byval(%struct.Big) align 4 %s)
anatofuz
parents:
diff changeset
257 // WIN64: define dso_local void @"?big_arg@@YAXUBig@@@Z"(%struct.Big* %s)
anatofuz
parents:
diff changeset
258
anatofuz
parents:
diff changeset
259 // PR27607: We would attempt to load i32 value out of the reference instead of
anatofuz
parents:
diff changeset
260 // just loading the pointer from the struct during argument expansion.
anatofuz
parents:
diff changeset
261 struct RefField {
anatofuz
parents:
diff changeset
262 RefField(int &x);
anatofuz
parents:
diff changeset
263 int &x;
anatofuz
parents:
diff changeset
264 };
anatofuz
parents:
diff changeset
265 void takes_ref_field(RefField s) {}
anatofuz
parents:
diff changeset
266 // LINUX-LABEL: define void @_Z15takes_ref_field8RefField(%struct.RefField* byval(%struct.RefField) align 4 %s)
anatofuz
parents:
diff changeset
267 // WIN32: define dso_local void @"?takes_ref_field@@YAXURefField@@@Z"(i32* %s.0)
anatofuz
parents:
diff changeset
268 // WIN64: define dso_local void @"?takes_ref_field@@YAXURefField@@@Z"(i64 %s.coerce)
anatofuz
parents:
diff changeset
269
anatofuz
parents:
diff changeset
270 void pass_ref_field() {
anatofuz
parents:
diff changeset
271 int x;
anatofuz
parents:
diff changeset
272 takes_ref_field(RefField(x));
anatofuz
parents:
diff changeset
273 }
anatofuz
parents:
diff changeset
274 // LINUX-LABEL: define void @_Z14pass_ref_fieldv()
anatofuz
parents:
diff changeset
275 // LINUX: call void @_Z15takes_ref_field8RefField(%struct.RefField* byval(%struct.RefField) align 4 %{{.*}})
anatofuz
parents:
diff changeset
276 // WIN32-LABEL: define dso_local void @"?pass_ref_field@@YAXXZ"()
anatofuz
parents:
diff changeset
277 // WIN32: call void @"?takes_ref_field@@YAXURefField@@@Z"(i32* %{{.*}})
anatofuz
parents:
diff changeset
278 // WIN64-LABEL: define dso_local void @"?pass_ref_field@@YAXXZ"()
anatofuz
parents:
diff changeset
279 // WIN64: call void @"?takes_ref_field@@YAXURefField@@@Z"(i64 %{{.*}})
anatofuz
parents:
diff changeset
280
anatofuz
parents:
diff changeset
281 class Class {
anatofuz
parents:
diff changeset
282 public:
anatofuz
parents:
diff changeset
283 Small thiscall_method_small() { return Small(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
284 // LINUX: define {{.*}} void @_ZN5Class21thiscall_method_smallEv(%struct.Small* noalias sret align 4 %agg.result, %class.Class* %this)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
285 // WIN32: define {{.*}} x86_thiscallcc void @"?thiscall_method_small@Class@@QAE?AUSmall@@XZ"(%class.Class* %this, %struct.Small* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
286 // WIN64: define linkonce_odr dso_local void @"?thiscall_method_small@Class@@QEAA?AUSmall@@XZ"(%class.Class* %this, %struct.Small* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
287
anatofuz
parents:
diff changeset
288 SmallWithCtor thiscall_method_small_with_ctor() { return SmallWithCtor(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
289 // LINUX: define {{.*}} void @_ZN5Class31thiscall_method_small_with_ctorEv(%struct.SmallWithCtor* noalias sret align 4 %agg.result, %class.Class* %this)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
290 // WIN32: define {{.*}} x86_thiscallcc void @"?thiscall_method_small_with_ctor@Class@@QAE?AUSmallWithCtor@@XZ"(%class.Class* %this, %struct.SmallWithCtor* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
291 // WIN64: define linkonce_odr dso_local void @"?thiscall_method_small_with_ctor@Class@@QEAA?AUSmallWithCtor@@XZ"(%class.Class* %this, %struct.SmallWithCtor* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
292
anatofuz
parents:
diff changeset
293 Small __cdecl cdecl_method_small() { return Small(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
294 // LINUX: define {{.*}} void @_ZN5Class18cdecl_method_smallEv(%struct.Small* noalias sret align 4 %agg.result, %class.Class* %this)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
295 // WIN32: define {{.*}} void @"?cdecl_method_small@Class@@QAA?AUSmall@@XZ"(%class.Class* %this, %struct.Small* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
296 // WIN64: define linkonce_odr dso_local void @"?cdecl_method_small@Class@@QEAA?AUSmall@@XZ"(%class.Class* %this, %struct.Small* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
297
anatofuz
parents:
diff changeset
298 Big __cdecl cdecl_method_big() { return Big(); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
299 // LINUX: define {{.*}} void @_ZN5Class16cdecl_method_bigEv(%struct.Big* noalias sret align 4 %agg.result, %class.Class* %this)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
300 // WIN32: define {{.*}} void @"?cdecl_method_big@Class@@QAA?AUBig@@XZ"(%class.Class* %this, %struct.Big* noalias sret align 4 %agg.result)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
301 // WIN64: define linkonce_odr dso_local void @"?cdecl_method_big@Class@@QEAA?AUBig@@XZ"(%class.Class* %this, %struct.Big* noalias sret align 4 %agg.result)
150
anatofuz
parents:
diff changeset
302
anatofuz
parents:
diff changeset
303 void thiscall_method_arg(Empty s) {}
anatofuz
parents:
diff changeset
304 // LINUX: define {{.*}} void @_ZN5Class19thiscall_method_argE5Empty(%class.Class* %this)
anatofuz
parents:
diff changeset
305 // WIN32: define {{.*}} void @"?thiscall_method_arg@Class@@QAEXUEmpty@@@Z"(%class.Class* %this, %struct.Empty* byval(%struct.Empty) align 4 %s)
anatofuz
parents:
diff changeset
306 // WIN64: define linkonce_odr dso_local void @"?thiscall_method_arg@Class@@QEAAXUEmpty@@@Z"(%class.Class* %this, i8 %s.coerce)
anatofuz
parents:
diff changeset
307
anatofuz
parents:
diff changeset
308 void thiscall_method_arg(EmptyWithCtor s) {}
anatofuz
parents:
diff changeset
309 // LINUX: define {{.*}} void @_ZN5Class19thiscall_method_argE13EmptyWithCtor(%class.Class* %this)
anatofuz
parents:
diff changeset
310 // WIN32: define {{.*}} void @"?thiscall_method_arg@Class@@QAEXUEmptyWithCtor@@@Z"(%class.Class* %this, %struct.EmptyWithCtor* byval(%struct.EmptyWithCtor) align 4 %s)
anatofuz
parents:
diff changeset
311 // WIN64: define linkonce_odr dso_local void @"?thiscall_method_arg@Class@@QEAAXUEmptyWithCtor@@@Z"(%class.Class* %this, i8 %s.coerce)
anatofuz
parents:
diff changeset
312
anatofuz
parents:
diff changeset
313 void thiscall_method_arg(Small s) {}
anatofuz
parents:
diff changeset
314 // LINUX: define {{.*}} void @_ZN5Class19thiscall_method_argE5Small(%class.Class* %this, i32 %s.0)
anatofuz
parents:
diff changeset
315 // WIN32: define {{.*}} void @"?thiscall_method_arg@Class@@QAEXUSmall@@@Z"(%class.Class* %this, i32 %s.0)
anatofuz
parents:
diff changeset
316 // WIN64: define linkonce_odr dso_local void @"?thiscall_method_arg@Class@@QEAAXUSmall@@@Z"(%class.Class* %this, i32 %s.coerce)
anatofuz
parents:
diff changeset
317
anatofuz
parents:
diff changeset
318 void thiscall_method_arg(SmallWithCtor s) {}
anatofuz
parents:
diff changeset
319 // LINUX: define {{.*}} void @_ZN5Class19thiscall_method_argE13SmallWithCtor(%class.Class* %this, %struct.SmallWithCtor* byval(%struct.SmallWithCtor) align 4 %s)
anatofuz
parents:
diff changeset
320 // WIN32: define {{.*}} void @"?thiscall_method_arg@Class@@QAEXUSmallWithCtor@@@Z"(%class.Class* %this, i32 %s.0)
anatofuz
parents:
diff changeset
321 // WIN64: define linkonce_odr dso_local void @"?thiscall_method_arg@Class@@QEAAXUSmallWithCtor@@@Z"(%class.Class* %this, i32 %s.coerce)
anatofuz
parents:
diff changeset
322
anatofuz
parents:
diff changeset
323 void thiscall_method_arg(Big s) {}
anatofuz
parents:
diff changeset
324 // LINUX: define {{.*}} void @_ZN5Class19thiscall_method_argE3Big(%class.Class* %this, %struct.Big* byval(%struct.Big) align 4 %s)
anatofuz
parents:
diff changeset
325 // WIN32: define {{.*}} void @"?thiscall_method_arg@Class@@QAEXUBig@@@Z"(%class.Class* %this, %struct.Big* byval(%struct.Big) align 4 %s)
anatofuz
parents:
diff changeset
326 // WIN64: define linkonce_odr dso_local void @"?thiscall_method_arg@Class@@QEAAXUBig@@@Z"(%class.Class* %this, %struct.Big* %s)
anatofuz
parents:
diff changeset
327 };
anatofuz
parents:
diff changeset
328
anatofuz
parents:
diff changeset
329 void use_class() {
anatofuz
parents:
diff changeset
330 Class c;
anatofuz
parents:
diff changeset
331 c.thiscall_method_small();
anatofuz
parents:
diff changeset
332 c.thiscall_method_small_with_ctor();
anatofuz
parents:
diff changeset
333
anatofuz
parents:
diff changeset
334 c.cdecl_method_small();
anatofuz
parents:
diff changeset
335 c.cdecl_method_big();
anatofuz
parents:
diff changeset
336
anatofuz
parents:
diff changeset
337 c.thiscall_method_arg(Empty());
anatofuz
parents:
diff changeset
338 c.thiscall_method_arg(EmptyWithCtor());
anatofuz
parents:
diff changeset
339 c.thiscall_method_arg(Small());
anatofuz
parents:
diff changeset
340 c.thiscall_method_arg(SmallWithCtor());
anatofuz
parents:
diff changeset
341 c.thiscall_method_arg(Big());
anatofuz
parents:
diff changeset
342 }
anatofuz
parents:
diff changeset
343
anatofuz
parents:
diff changeset
344 struct X {
anatofuz
parents:
diff changeset
345 X();
anatofuz
parents:
diff changeset
346 ~X();
anatofuz
parents:
diff changeset
347 };
anatofuz
parents:
diff changeset
348 void g(X) {
anatofuz
parents:
diff changeset
349 }
anatofuz
parents:
diff changeset
350 // WIN32: define dso_local void @"?g@@YAXUX@@@Z"(<{ %struct.X, [3 x i8] }>* inalloca %0) {{.*}} {
anatofuz
parents:
diff changeset
351 // WIN32: call x86_thiscallcc void @"??1X@@QAE@XZ"(%struct.X* {{.*}})
anatofuz
parents:
diff changeset
352 // WIN32: }
anatofuz
parents:
diff changeset
353 void f() {
anatofuz
parents:
diff changeset
354 g(X());
anatofuz
parents:
diff changeset
355 }
anatofuz
parents:
diff changeset
356 // WIN32: define dso_local void @"?f@@YAXXZ"() {{.*}} {
anatofuz
parents:
diff changeset
357 // WIN32-NOT: call {{.*}} @"??1X@@QAE@XZ"
anatofuz
parents:
diff changeset
358 // WIN32: }
anatofuz
parents:
diff changeset
359
anatofuz
parents:
diff changeset
360
anatofuz
parents:
diff changeset
361 namespace test2 {
anatofuz
parents:
diff changeset
362 // We used to crash on this due to the mixture of POD byval and non-trivial
anatofuz
parents:
diff changeset
363 // byval.
anatofuz
parents:
diff changeset
364
anatofuz
parents:
diff changeset
365 struct NonTrivial {
anatofuz
parents:
diff changeset
366 NonTrivial();
anatofuz
parents:
diff changeset
367 NonTrivial(const NonTrivial &o);
anatofuz
parents:
diff changeset
368 ~NonTrivial();
anatofuz
parents:
diff changeset
369 int a;
anatofuz
parents:
diff changeset
370 };
anatofuz
parents:
diff changeset
371 struct POD { int b; };
anatofuz
parents:
diff changeset
372
anatofuz
parents:
diff changeset
373 int foo(NonTrivial a, POD b);
anatofuz
parents:
diff changeset
374 void bar() {
anatofuz
parents:
diff changeset
375 POD b;
anatofuz
parents:
diff changeset
376 b.b = 13;
anatofuz
parents:
diff changeset
377 int c = foo(NonTrivial(), b);
anatofuz
parents:
diff changeset
378 }
anatofuz
parents:
diff changeset
379 // WIN32-LABEL: define dso_local void @"?bar@test2@@YAXXZ"() {{.*}} {
anatofuz
parents:
diff changeset
380 // WIN32: %[[argmem:[^ ]*]] = alloca inalloca [[argmem_ty:<{ %"struct.test2::NonTrivial", %"struct.test2::POD" }>]]
anatofuz
parents:
diff changeset
381 // WIN32: getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 1
anatofuz
parents:
diff changeset
382 // WIN32: call void @llvm.memcpy
anatofuz
parents:
diff changeset
383 // WIN32: getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 0
anatofuz
parents:
diff changeset
384 // WIN32: call x86_thiscallcc %"struct.test2::NonTrivial"* @"??0NonTrivial@test2@@QAE@XZ"
anatofuz
parents:
diff changeset
385 // WIN32: call i32 @"?foo@test2@@YAHUNonTrivial@1@UPOD@1@@Z"([[argmem_ty]]* inalloca %argmem)
anatofuz
parents:
diff changeset
386 // WIN32: ret void
anatofuz
parents:
diff changeset
387 // WIN32: }
anatofuz
parents:
diff changeset
388
anatofuz
parents:
diff changeset
389 }
anatofuz
parents:
diff changeset
390
anatofuz
parents:
diff changeset
391 namespace test3 {
anatofuz
parents:
diff changeset
392
anatofuz
parents:
diff changeset
393 // Check that we padded the inalloca struct to a multiple of 4.
anatofuz
parents:
diff changeset
394 struct NonTrivial {
anatofuz
parents:
diff changeset
395 NonTrivial();
anatofuz
parents:
diff changeset
396 NonTrivial(const NonTrivial &o);
anatofuz
parents:
diff changeset
397 ~NonTrivial();
anatofuz
parents:
diff changeset
398 int a;
anatofuz
parents:
diff changeset
399 };
anatofuz
parents:
diff changeset
400 void foo(NonTrivial a, bool b) { }
anatofuz
parents:
diff changeset
401 // WIN32-LABEL: define dso_local void @"?foo@test3@@YAXUNonTrivial@1@_N@Z"(<{ %"struct.test3::NonTrivial", i8, [3 x i8] }>* inalloca %0)
anatofuz
parents:
diff changeset
402
anatofuz
parents:
diff changeset
403 }
anatofuz
parents:
diff changeset
404
anatofuz
parents:
diff changeset
405 // We would crash here because the later definition of ForwardDeclare1 results
anatofuz
parents:
diff changeset
406 // in a different IR type for the value we want to store. However, the alloca's
anatofuz
parents:
diff changeset
407 // type will use the argument type selected by fn1.
anatofuz
parents:
diff changeset
408 struct ForwardDeclare1;
anatofuz
parents:
diff changeset
409
anatofuz
parents:
diff changeset
410 typedef void (*FnPtr1)(ForwardDeclare1);
anatofuz
parents:
diff changeset
411 void fn1(FnPtr1 a, SmallWithDtor b) { }
anatofuz
parents:
diff changeset
412
anatofuz
parents:
diff changeset
413 struct ForwardDeclare1 {};
anatofuz
parents:
diff changeset
414
anatofuz
parents:
diff changeset
415 void fn2(FnPtr1 a, SmallWithDtor b) { fn1(a, b); };
anatofuz
parents:
diff changeset
416 // WIN32-LABEL: define dso_local void @"?fn2@@YAXP6AXUForwardDeclare1@@@ZUSmallWithDtor@@@Z"
anatofuz
parents:
diff changeset
417 // WIN32: %[[a:[^ ]*]] = getelementptr inbounds [[argmem_ty:<{ {}\*, %struct.SmallWithDtor }>]], [[argmem_ty:<{ {}\*, %struct.SmallWithDtor }>]]* %{{.*}}, i32 0, i32 0
anatofuz
parents:
diff changeset
418 // WIN32: %[[a1:[^ ]*]] = bitcast {}** %[[a]] to void [[dst_ty:\(%struct.ForwardDeclare1\*\)\*]]*
anatofuz
parents:
diff changeset
419 // WIN32: %[[argmem:[^ ]*]] = alloca inalloca [[argmem_ty]]
anatofuz
parents:
diff changeset
420 // WIN32: %[[gep1:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 1
anatofuz
parents:
diff changeset
421 // WIN32: %[[bc1:[^ ]*]] = bitcast %struct.SmallWithDtor* %[[gep1]] to i8*
anatofuz
parents:
diff changeset
422 // WIN32: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %[[bc1]], i8* align 4 {{.*}}, i32 4, i1 false)
anatofuz
parents:
diff changeset
423 // WIN32: %[[a2:[^ ]*]] = load void [[dst_ty]], void [[dst_ty]]* %[[a1]], align 4
anatofuz
parents:
diff changeset
424 // WIN32: %[[gep2:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 0
anatofuz
parents:
diff changeset
425 // WIN32: %[[addr:[^ ]*]] = bitcast {}** %[[gep2]] to void [[dst_ty]]*
anatofuz
parents:
diff changeset
426 // WIN32: store void [[dst_ty]] %[[a2]], void [[dst_ty]]* %[[addr]], align 4
anatofuz
parents:
diff changeset
427 // WIN32: call void @"?fn1@@YAXP6AXUForwardDeclare1@@@ZUSmallWithDtor@@@Z"([[argmem_ty]]* inalloca %[[argmem]])
anatofuz
parents:
diff changeset
428
anatofuz
parents:
diff changeset
429 namespace pr30293 {
anatofuz
parents:
diff changeset
430 // Virtual methods living in a secondary vtable take i8* as their 'this'
anatofuz
parents:
diff changeset
431 // parameter because the 'this' parameter on entry points to the secondary
anatofuz
parents:
diff changeset
432 // vptr. We used to have a bug where we didn't apply this rule consistently,
anatofuz
parents:
diff changeset
433 // and it would cause assertion failures when used with inalloca.
anatofuz
parents:
diff changeset
434 struct A {
anatofuz
parents:
diff changeset
435 virtual void f();
anatofuz
parents:
diff changeset
436 };
anatofuz
parents:
diff changeset
437 struct B {
anatofuz
parents:
diff changeset
438 virtual void __cdecl h(SmallWithDtor);
anatofuz
parents:
diff changeset
439 };
anatofuz
parents:
diff changeset
440 struct C final : A, B {
anatofuz
parents:
diff changeset
441 void g();
anatofuz
parents:
diff changeset
442 void __cdecl h(SmallWithDtor);
anatofuz
parents:
diff changeset
443 void f();
anatofuz
parents:
diff changeset
444 };
anatofuz
parents:
diff changeset
445 void C::g() { return h(SmallWithDtor()); }
anatofuz
parents:
diff changeset
446
anatofuz
parents:
diff changeset
447 // WIN32-LABEL: define dso_local x86_thiscallcc void @"?g@C@pr30293@@QAEXXZ"(%"struct.pr30293::C"* %this)
anatofuz
parents:
diff changeset
448 // WIN32: call x86_thiscallcc %struct.SmallWithDtor* @"??0SmallWithDtor@@QAE@XZ"
anatofuz
parents:
diff changeset
449 // WIN32: call void @"?h@C@pr30293@@UAAXUSmallWithDtor@@@Z"(<{ i8*, %struct.SmallWithDtor }>* inalloca %{{[^,)]*}})
anatofuz
parents:
diff changeset
450 // WIN32: declare dso_local void @"?h@C@pr30293@@UAAXUSmallWithDtor@@@Z"(<{ i8*, %struct.SmallWithDtor }>* inalloca)
anatofuz
parents:
diff changeset
451
anatofuz
parents:
diff changeset
452 // WIN64-LABEL: define dso_local void @"?g@C@pr30293@@QEAAXXZ"(%"struct.pr30293::C"* %this)
anatofuz
parents:
diff changeset
453 // WIN64: declare dso_local void @"?h@C@pr30293@@UEAAXUSmallWithDtor@@@Z"(i8*, i32)
anatofuz
parents:
diff changeset
454 }