1 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-gnu-linux -O3 -disable-llvm-passes -I%S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN,LIN64,NoNewStructPathTBAA
2 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-gnu-linux -O3 -disable-llvm-passes -I%S -new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN,LIN64,NewStructPathTBAA
4 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-pc -O3 -disable-llvm-passes -I%S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN,WIN64,NoNewStructPathTBAA
5 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-pc -O3 -disable-llvm-passes -I%S -new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN,WIN64,NewStructPathTBAA
7 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i386-gnu-linux -O3 -disable-llvm-passes -I%S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN,LIN32,NoNewStructPathTBAA
8 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i386-gnu-linux -O3 -disable-llvm-passes -I%S -new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN,LIN32,NewStructPathTBAA
10 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i386-windows-pc -O3 -disable-llvm-passes -I%S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN,WIN32,NoNewStructPathTBAA
11 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i386-windows-pc -O3 -disable-llvm-passes -I%S -new-struct-path-tbaa -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN,WIN32,NewStructPathTBAA
14 class type_info
{ public: virtual ~type_info(); private: const char * name
; };
17 // Ensure that the layout for these structs is the same as the normal bitfield
19 struct BitFieldsByte
{
24 // CHECK: %struct.BitFieldsByte = type { i8 }
26 struct BitFieldsShort
{
31 // LIN: %struct.BitFieldsShort = type { i8, i8 }
32 // WIN: %struct.BitFieldsShort = type { i16 }
39 // LIN: %struct.BitFieldsInt = type { i8, [3 x i8] }
40 // WIN: %struct.BitFieldsInt = type { i32 }
42 struct BitFieldsLong
{
47 // LIN64: %struct.BitFieldsLong = type { i8, [7 x i8] }
48 // LIN32: %struct.BitFieldsLong = type { i8, [3 x i8] }
49 // WIN: %struct.BitFieldsLong = type { i64 }
51 struct HasBitIntFirst
{
55 // CHECK: %struct.HasBitIntFirst = type { i64, i32 }
57 struct HasBitIntLast
{
61 // CHECK: %struct.HasBitIntLast = type { i32, i64 }
63 struct HasBitIntMiddle
{
68 // CHECK: %struct.HasBitIntMiddle = type { i32, i64, i32 }
70 // Force emitting of the above structs.
82 void BitfieldAssignment() {
83 // LIN: define{{.*}} void @_Z18BitfieldAssignmentv
84 // WIN: define dso_local void @"?BitfieldAssignment@@YAXXZ"
89 // First one is used for the lifetime start, skip that.
90 // CHECK: %[[LOADA:.+]] = load i8, ptr %[[BFType:.*]]
91 // CHECK: %[[CLEARA:.+]] = and i8 %[[LOADA]], -8
92 // CHECK: %[[SETA:.+]] = or i8 %[[CLEARA]], 3
93 // CHECK: %[[LOADB:.+]] = load i8, ptr %[[BFType:.*]]
94 // CHECK: %[[CLEARB:.+]] = and i8 %[[LOADB]], -57
95 // CHECK: %[[SETB:.+]] = or i8 %[[CLEARB]], 16
96 // CHECK: %[[LOADC:.+]] = load i8, ptr %[[BFType:.*]]
97 // CHECK: %[[CLEARC:.+]] = and i8 %[[LOADC]], 63
98 // CHECK: %[[SETC:.+]] = or i8 %[[CLEARC]], 64
101 unsigned _BitInt(33) ManglingTestRetParam(unsigned _BitInt(33) Param
) {
102 // LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamDU33_(i64 %
103 // LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamDU33_(i33 %
104 // WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_UBitInt@$0CB@@__clang@@U12@@Z"(i33
108 _BitInt(33) ManglingTestRetParam(_BitInt(33) Param
) {
109 // LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamDB33_(i64 %
110 // LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamDB33_(i33 %
111 // WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_BitInt@$0CB@@__clang@@U12@@Z"(i33
115 typedef unsigned _BitInt(16) uint16_t4
__attribute__((ext_vector_type(4)));
116 typedef _BitInt(32) vint32_t8
__attribute__((vector_size(32)));
119 void ManglingTestTemplateParam(T
&);
120 template<_BitInt(99) T
>
121 void ManglingTestNTTP();
123 auto ManglingDependent() -> decltype(_BitInt(N
){});
125 void ManglingInstantiator() {
126 // LIN: define{{.*}} void @_Z20ManglingInstantiatorv()
127 // WIN: define dso_local void @"?ManglingInstantiator@@YAXXZ"()
129 ManglingTestTemplateParam(A
);
130 // LIN: call void @_Z25ManglingTestTemplateParamIDB93_EvRT_(ptr
131 // WIN64: call void @"??$ManglingTestTemplateParam@U?$_BitInt@$0FN@@__clang@@@@YAXAEAU?$_BitInt@$0FN@@__clang@@@Z"(ptr
132 // WIN32: call void @"??$ManglingTestTemplateParam@U?$_BitInt@$0FN@@__clang@@@@YAXAAU?$_BitInt@$0FN@@__clang@@@Z"(ptr
133 constexpr _BitInt(93) B
= 993;
134 ManglingTestNTTP
<38>();
135 // LIN: call void @_Z16ManglingTestNTTPILDB99_38EEvv()
136 // WIN: call void @"??$ManglingTestNTTP@$0CG@@@YAXXZ"()
137 ManglingTestNTTP
<B
>();
138 // LIN: call void @_Z16ManglingTestNTTPILDB99_993EEvv()
139 // WIN: call void @"??$ManglingTestNTTP@$0DOB@@@YAXXZ"()
140 ManglingDependent
<4>();
141 // LIN: call signext i4 @_Z17ManglingDependentILi4EEDTtlDBT__EEv()
142 // WIN64: call i4 @"??$ManglingDependent@$03@@YAU?$_BitInt@$03@__clang@@XZ"()
143 // WIN32: call signext i4 @"??$ManglingDependent@$03@@YAU?$_BitInt@$03@__clang@@XZ"()
145 ManglingTestTemplateParam(V
);
146 // LIN: call void @_Z25ManglingTestTemplateParamIDv4_DU16_EvRT_(ptr
147 // WIN64: call void @"??$ManglingTestTemplateParam@T?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@@@YAXAEAT?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@@Z"(ptr
148 // WIN32: call void @"??$ManglingTestTemplateParam@T?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@@@YAXAAT?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@@Z"(ptr
152 void TakesVarargs(int i
, ...) {
153 // LIN: define{{.*}} void @_Z12TakesVarargsiz(i32 %i, ...)
154 // WIN: define dso_local void @"?TakesVarargs@@YAXHZZ"(i32 %i, ...)
156 __builtin_va_list args
;
157 // LIN64: %[[ARGS:.+]] = alloca [1 x %struct.__va_list_tag]
158 // LIN32: %[[ARGS:.+]] = alloca ptr
159 // WIN: %[[ARGS:.+]] = alloca ptr
160 __builtin_va_start(args
, i
);
161 // LIN64: %[[STARTAD:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
162 // LIN64: call void @llvm.va_start.p0(ptr %[[STARTAD]])
163 // LIN32: call void @llvm.va_start.p0(ptr %[[ARGS]])
164 // WIN: call void @llvm.va_start.p0(ptr %[[ARGS]])
166 _BitInt(92) A
= __builtin_va_arg(args
, _BitInt(92));
167 // LIN64: %[[AD1:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
168 // LIN64: %[[OFA_P1:.+]] = getelementptr inbounds nuw %struct.__va_list_tag, ptr %[[AD1]], i32 0, i32 0
169 // LIN64: %[[GPOFFSET:.+]] = load i32, ptr %[[OFA_P1]]
170 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 32
171 // LIN64: br i1 %[[FITSINGP]]
172 // LIN64: %[[BC1:.+]] = phi ptr
173 // LIN64: %[[LOAD1:.+]] = load i128, ptr %[[BC1]]
174 // LIN64: %[[T:.+]] = trunc i128 %[[LOAD1]] to i92
175 // LIN64: %[[S:.+]] = sext i92 %[[T]] to i128
176 // LIN64: store i128 %[[S]], ptr
178 // LIN32: %[[CUR1:.+]] = load ptr, ptr %[[ARGS]]
179 // LIN32: %[[NEXT1:.+]] = getelementptr inbounds i8, ptr %[[CUR1]], i32 12
180 // LIN32: store ptr %[[NEXT1]], ptr %[[ARGS]]
181 // LIN32: %[[LOADV1:.+]] = load i96, ptr %[[CUR1]]
182 // LIN32: %[[TR:.+]] = trunc i96 %[[LOADV1]] to i92
183 // LIN32: %[[SEXT:.+]] = sext i92 %[[TR]] to i96
184 // LIN32: store i96 %[[SEXT]], ptr
186 // WIN64: %[[CUR1:.+]] = load ptr, ptr %[[ARGS]]
187 // WIN64: %[[NEXT1:.+]] = getelementptr inbounds i8, ptr %[[CUR1]], i64 8
188 // WIN64: store ptr %[[NEXT1]], ptr %[[ARGS]]
189 // WIN64: %[[LOADP1:.+]] = load ptr, ptr %[[CUR1]]
190 // WIN64: %[[LOADV1:.+]] = load i128, ptr %[[LOADP1]]
191 // WIN64: %[[TR:.+]] = trunc i128 %[[LOADV1]] to i92
192 // WIN64: %[[SEXT:.+]] = sext i92 %[[TR]] to i128
193 // WIN64: store i128 %[[SEXT]], ptr
195 // WIN32: %[[CUR1:.+]] = load ptr, ptr %[[ARGS]]
196 // WIN32: %[[NEXT1:.+]] = getelementptr inbounds i8, ptr %[[CUR1]], i32 16
197 // WIN32: store ptr %[[NEXT1]], ptr %[[ARGS]]
198 // WIN32: %[[LOADV1:.+]] = load i128, ptr %[[CUR1]]
199 // WIN32: %[[TR:.+]] = trunc i128 %[[LOADV1]] to i92
200 // WIN32: %[[SEXT:.+]] = sext i92 %[[TR]] to i128
201 // WIN32: store i128 %[[SEXT]], ptr
204 _BitInt(31) B
= __builtin_va_arg(args
, _BitInt(31));
205 // LIN64: %[[AD2:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
206 // LIN64: %[[OFA_P2:.+]] = getelementptr inbounds nuw %struct.__va_list_tag, ptr %[[AD2]], i32 0, i32 0
207 // LIN64: %[[GPOFFSET:.+]] = load i32, ptr %[[OFA_P2]]
208 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 40
209 // LIN64: br i1 %[[FITSINGP]]
210 // LIN64: %[[BC1:.+]] = phi ptr
211 // LIN64: %[[LOAD1:.+]] = load i32, ptr %[[BC1]]
212 // LIN64: %[[T:.+]] = trunc i32 %[[LOAD1]] to i31
213 // LIN64: %[[S:.+]] = sext i31 %[[T]] to i32
214 // LIN64: store i32 %[[S]], ptr
216 // LIN32: %[[CUR2:.+]] = load ptr, ptr %[[ARGS]]
217 // LIN32: %[[NEXT2:.+]] = getelementptr inbounds i8, ptr %[[CUR2]], i32 4
218 // LIN32: store ptr %[[NEXT2]], ptr %[[ARGS]]
219 // LIN32: %[[LOADV2:.+]] = load i32, ptr %[[CUR2]]
220 // LIN32: %[[T:.+]] = trunc i32 %[[LOADV2]] to i31
221 // LIN32: %[[S:.+]] = sext i31 %[[T]] to i32
222 // LIN32: store i32 %[[S]], ptr
224 // WIN64: %[[CUR2:.+]] = load ptr, ptr %[[ARGS]]
225 // WIN64: %[[NEXT2:.+]] = getelementptr inbounds i8, ptr %[[CUR2]], i64 8
226 // WIN64: store ptr %[[NEXT2]], ptr %[[ARGS]]
227 // WIN64: %[[LOADV2:.+]] = load i32, ptr %[[CUR2]]
228 // WIN64: %[[T:.+]] = trunc i32 %[[LOADV2]] to i31
229 // WIN64: %[[S:.+]] = sext i31 %[[T]] to i32
230 // WIN64: store i32 %[[S]], ptr
232 // WIN32: %[[CUR2:.+]] = load ptr, ptr %[[ARGS]]
233 // WIN32: %[[NEXT2:.+]] = getelementptr inbounds i8, ptr %[[CUR2]], i32 4
234 // WIN32: store ptr %[[NEXT2]], ptr %[[ARGS]]
235 // WIN32: %[[LOADV2:.+]] = load i32, ptr %[[CUR2]]
236 // WIN32: %[[T:.+]] = trunc i32 %[[LOADV2]] to i31
237 // WIN32: %[[S:.+]] = sext i31 %[[T]] to i32
238 // WIN32: store i32 %[[S]], ptr
240 _BitInt(16) C
= __builtin_va_arg(args
, _BitInt(16));
241 // LIN64: %[[AD3:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
242 // LIN64: %[[OFA_P3:.+]] = getelementptr inbounds nuw %struct.__va_list_tag, ptr %[[AD3]], i32 0, i32 0
243 // LIN64: %[[GPOFFSET:.+]] = load i32, ptr %[[OFA_P3]]
244 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 40
245 // LIN64: br i1 %[[FITSINGP]]
246 // LIN64: %[[BC1:.+]] = phi ptr
247 // LIN64: %[[LOAD1:.+]] = load i16, ptr %[[BC1]]
248 // LIN64: store i16 %[[LOAD1]], ptr
250 // LIN32: %[[CUR3:.+]] = load ptr, ptr %[[ARGS]]
251 // LIN32: %[[NEXT3:.+]] = getelementptr inbounds i8, ptr %[[CUR3]], i32 4
252 // LIN32: store ptr %[[NEXT3]], ptr %[[ARGS]]
253 // LIN32: %[[LOADV3:.+]] = load i16, ptr %[[CUR3]]
254 // LIN32: store i16 %[[LOADV3]], ptr
256 // WIN64: %[[CUR3:.+]] = load ptr, ptr %[[ARGS]]
257 // WIN64: %[[NEXT3:.+]] = getelementptr inbounds i8, ptr %[[CUR3]], i64 8
258 // WIN64: store ptr %[[NEXT3]], ptr %[[ARGS]]
259 // WIN64: %[[LOADV3:.+]] = load i16, ptr %[[CUR3]]
260 // WIN64: store i16 %[[LOADV3]], ptr
262 // WIN32: %[[CUR3:.+]] = load ptr, ptr %[[ARGS]]
263 // WIN32: %[[NEXT3:.+]] = getelementptr inbounds i8, ptr %[[CUR3]], i32 4
264 // WIN32: store ptr %[[NEXT3]], ptr %[[ARGS]]
265 // WIN32: %[[LOADV3:.+]] = load i16, ptr %[[CUR3]]
266 // WIN32: store i16 %[[LOADV3]], ptr
268 uint16_t4 D
= __builtin_va_arg(args
, uint16_t4
);
269 // LIN64: %[[AD4:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
270 // LIN64: %[[OFA_P4:.+]] = getelementptr inbounds nuw %struct.__va_list_tag, ptr %[[AD4]], i32 0, i32 1
271 // LIN64: %[[GPOFFSET:.+]] = load i32, ptr %[[OFA_P4]]
272 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 160
273 // LIN64: br i1 %[[FITSINGP]]
274 // LIN64: %[[BC4:.+]] = phi ptr
275 // LIN64: %[[LOADV4:.+]] = load <4 x i16>, ptr %[[BC4]]
276 // LIN64: store <4 x i16> %[[LOADV4]], ptr
278 // LIN32: %[[CUR4:.+]] = load ptr, ptr %[[ARGS]]
279 // LIN32: %[[NEXT4:.+]] = getelementptr inbounds i8, ptr %[[CUR4]], i32 8
280 // LIN32: store ptr %[[NEXT4]], ptr %[[ARGS]]
281 // LIN32: %[[LOADV4:.+]] = load <4 x i16>, ptr %[[CUR4]]
282 // LIN32: store <4 x i16> %[[LOADV4]], ptr %
284 // WIN: %[[CUR4:.+]] = load ptr, ptr %[[ARGS]]
285 // WIN64: %[[NEXT4:.+]] = getelementptr inbounds i8, ptr %[[CUR4]], i64 8
286 // WIN32: %[[NEXT4:.+]] = getelementptr inbounds i8, ptr %[[CUR4]], i32 8
287 // WIN: store ptr %[[NEXT4]], ptr %[[ARGS]]
288 // WIN: %[[LOADV4:.+]] = load <4 x i16>, ptr %[[CUR4]]
289 // WIN: store <4 x i16> %[[LOADV4]], ptr
291 vint32_t8 E
= __builtin_va_arg(args
, vint32_t8
);
292 // LIN64: %[[AD5:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
293 // LIN64: %[[OFAA_P4:.+]] = getelementptr inbounds nuw %struct.__va_list_tag, ptr %[[AD5]], i32 0, i32 2
294 // LIN64: %[[OFAA:.+]] = load ptr, ptr %[[OFAA_P4]]
296 // LIN64: [[OFAA_GEP:%.*]] = getelementptr inbounds i8, ptr %[[OFAA]], i32 31
297 // LIN64: %[[OFAA_ALIGNED:.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[OFAA_GEP]], i64 -32)
298 // LIN64: %[[LOADV5:.+]] = load <8 x i32>, ptr %[[OFAA_ALIGNED]]
299 // LIN64: store <8 x i32> %[[LOADV5]], ptr
301 // LIN32: %[[CUR5:.+]] = load ptr, ptr %[[ARGS]]
303 // LIN32: [[GEP_CUR5:%.*]] = getelementptr inbounds i8, ptr %[[CUR5]], i32 31
304 // LIN32: %[[CUR5_ALIGNED:.*]] = call ptr @llvm.ptrmask.p0.i32(ptr [[GEP_CUR5]], i32 -32)
305 // LIN32: %[[NEXT5:.+]] = getelementptr inbounds i8, ptr %[[CUR5_ALIGNED]], i32 32
306 // LIN32: store ptr %[[NEXT5]], ptr %[[ARGS]]
307 // LIN32: %[[LOADV5:.+]] = load <8 x i32>, ptr %[[CUR5_ALIGNED]]
308 // LIN32: store <8 x i32> %[[LOADV5]], ptr
310 // WIN: %[[CUR5:.+]] = load ptr, ptr %[[ARGS]]
311 // WIN64: %[[NEXT5:.+]] = getelementptr inbounds i8, ptr %[[CUR5]], i64 8
312 // WIN32: %[[NEXT5:.+]] = getelementptr inbounds i8, ptr %[[CUR5]], i32 32
313 // WIN: store ptr %[[NEXT5]], ptr %[[ARGS]]
314 // WIN64: %[[LOADP5:.+]] = load ptr, ptr %[[CUR5]]
315 // WIN64: %[[LOADV5:.+]] = load <8 x i32>, ptr %[[LOADP5]]
316 // WIN32: %[[LOADV5:.+]] = load <8 x i32>, ptr %argp.cur9
317 // WIN: store <8 x i32> %[[LOADV5]], ptr
319 __builtin_va_end(args
);
320 // LIN64: %[[ENDAD:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
321 // LIN64: call void @llvm.va_end.p0(ptr %[[ENDAD]])
322 // LIN32: call void @llvm.va_end.p0(ptr %[[ARGS]])
323 // WIN: call void @llvm.va_end.p0(ptr %[[ARGS]])
325 void typeid_tests() {
326 // LIN: define{{.*}} void @_Z12typeid_testsv()
327 // WIN: define dso_local void @"?typeid_tests@@YAXXZ"()
328 unsigned _BitInt(33) U33_1
, U33_2
;
329 _BitInt(33) S33_1
, S33_2
;
330 _BitInt(32) S32_1
, S32_2
;
332 auto A
= typeid(U33_1
);
333 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDU33_)
334 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDU33_)
335 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_UBitInt@$0CB@@__clang@@@8")
336 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_UBitInt@$0CB@@__clang@@@8")
337 auto B
= typeid(U33_2
);
338 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDU33_)
339 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDU33_)
340 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_UBitInt@$0CB@@__clang@@@8")
341 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_UBitInt@$0CB@@__clang@@@8")
342 auto C
= typeid(S33_1
);
343 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDB33_)
344 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDB33_)
345 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_BitInt@$0CB@@__clang@@@8")
346 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_BitInt@$0CB@@__clang@@@8")
347 auto D
= typeid(S33_2
);
348 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDB33_)
349 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDB33_)
350 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_BitInt@$0CB@@__clang@@@8")
351 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_BitInt@$0CB@@__clang@@@8")
352 auto E
= typeid(S32_1
);
353 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDB32_)
354 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDB32_)
355 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_BitInt@$0CA@@__clang@@@8")
356 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_BitInt@$0CA@@__clang@@@8")
357 auto F
= typeid(S32_2
);
358 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDB32_)
359 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDB32_)
360 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_BitInt@$0CA@@__clang@@@8")
361 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_BitInt@$0CA@@__clang@@@8")
362 auto G
= typeid(uint16_t4
);
363 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDv4_DU16_)
364 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDv4_DU16_)
365 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0T?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@@8")
366 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0T?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@@8")
367 auto H
= typeid(vint32_t8
);
368 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDv8_DB32_)
369 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDv8_DB32_)
370 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0?AT?$__vector@U?$_BitInt@$0CA@@__clang@@$07@__clang@@@8")
371 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0?AT?$__vector@U?$_BitInt@$0CA@@__clang@@$07@__clang@@@8")
374 void ExplicitCasts() {
375 // LIN: define{{.*}} void @_Z13ExplicitCastsv()
376 // WIN: define dso_local void @"?ExplicitCasts@@YAXXZ"()
383 // CHECK: %[[CONV:.+]] = sext i32 %{{.+}} to i33
385 // CHECK: %[[CONV:.+]] = trunc i32 %{{.+}} to i31
387 // CHECK: %[[CONV:.+]] = trunc i33 %{{.+}} to i32
389 // CHECK: %[[CONV:.+]] = sext i31 %{{.+}} to i32
392 // CHECK: %[[CONV:.+]] = trunc i32 %{{.+}} to i16
393 // CHECK: %[[VEC:.+]] = insertelement <4 x i16> poison, i16 %[[CONV]], i64 0
394 // CHECK: %[[Splat:.+]] = shufflevector <4 x i16> %[[VEC]], <4 x i16> poison, <4 x i32> zeroinitializer
405 void OffsetOfTest() {
406 // LIN: define{{.*}} void @_Z12OffsetOfTestv()
407 // WIN: define dso_local void @"?OffsetOfTest@@YAXXZ"()
409 auto A
= __builtin_offsetof(S
,A
);
410 // CHECK: store i{{.+}} 0, ptr %{{.+}}
411 auto B
= __builtin_offsetof(S
,B
);
412 // LIN64: store i{{.+}} 8, ptr %{{.+}}
413 // LIN32: store i{{.+}} 4, ptr %{{.+}}
414 // WIN: store i{{.+}} 8, ptr %{{.+}}
415 auto C
= __builtin_offsetof(S
,C
);
416 // LIN64: store i{{.+}} 24, ptr %{{.+}}
417 // LIN32: store i{{.+}} 20, ptr %{{.+}}
418 // WIN: store i{{.+}} 24, ptr %{{.+}}
419 auto D
= __builtin_offsetof(S
,D
);
420 // LIN64: store i64 32, ptr %{{.+}}
421 // LIN32: store i32 24, ptr %{{.+}}
422 // WIN: store i{{.+}} 32, ptr %{{.+}}
423 auto E
= __builtin_offsetof(S
,E
);
424 // LIN64: store i64 64, ptr %{{.+}}
425 // LIN32: store i32 32, ptr %{{.+}}
426 // WIN: store i{{.+}} 64, ptr %{{.+}}
430 void ShiftBitIntByConstant(_BitInt(28) Ext
) {
431 // LIN: define{{.*}} void @_Z21ShiftBitIntByConstantDB28_
432 // WIN: define dso_local void @"?ShiftBitIntByConstant@@YAXU?$_BitInt@$0BM@@__clang@@@Z"
434 // CHECK: shl i28 %{{.+}}, 7
436 // CHECK: ashr i28 %{{.+}}, 7
438 // CHECK: shl i28 %{{.+}}, -7
440 // CHECK: ashr i28 %{{.+}}, -7
442 // UB in C/C++, Defined in OpenCL.
444 // CHECK: shl i28 %{{.+}}, 29
446 // CHECK: ashr i28 %{{.+}}, 29
448 void ShiftBitIntByConstant(uint16_t4 Ext
) {
449 // LIN64: define{{.*}} void @_Z21ShiftBitIntByConstantDv4_DU16_(double %
450 // LIN32: define dso_local void @_Z21ShiftBitIntByConstantDv4_DU16_(i64 %
451 // WIN: define dso_local void @"?ShiftBitIntByConstant@@YAXT?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@@Z"(<4 x i16>
453 // CHECK: shl <4 x i16> %{{.+}}, splat (i16 7)
455 // CHECK: lshr <4 x i16> %{{.+}}, splat (i16 7)
457 // CHECK: shl <4 x i16> %{{.+}}, splat (i16 -7)
459 // CHECK: lshr <4 x i16> %{{.+}}, splat (i16 -7)
461 // UB in C/C++, Defined in OpenCL.
463 // CHECK: shl <4 x i16> %{{.+}}, splat (i16 29)
465 // CHECK: lshr <4 x i16> %{{.+}}, splat (i16 29)
467 void ShiftBitIntByConstant(vint32_t8 Ext
) {
468 // LIN64: define{{.*}} void @_Z21ShiftBitIntByConstantDv8_DB32_(ptr byval(<8 x i32>) align 32 %
469 // LIN32: define dso_local void @_Z21ShiftBitIntByConstantDv8_DB32_(<8 x i32> %
470 // WIN: define dso_local void @"?ShiftBitIntByConstant@@YAXT?$__vector@U?$_BitInt@$0CA@@__clang@@$07@__clang@@@Z"(<8 x i32>
472 // CHECK: shl <8 x i32> %{{.+}}, splat (i32 7)
474 // CHECK: ashr <8 x i32> %{{.+}}, splat (i32 7)
476 // CHECK: shl <8 x i32> %{{.+}}, splat (i32 -7)
478 // CHECK: ashr <8 x i32> %{{.+}}, splat (i32 -7)
480 // UB in C/C++, Defined in OpenCL.
482 // CHECK: shl <8 x i32> %{{.+}}, splat (i32 29)
484 // CHECK: ashr <8 x i32> %{{.+}}, splat (i32 29)
487 void ConstantShiftByBitInt(_BitInt(28) Ext
, _BitInt(65) LargeExt
) {
488 // LIN: define{{.*}} void @_Z21ConstantShiftByBitIntDB28_DB65_
489 // WIN: define dso_local void @"?ConstantShiftByBitInt@@YAXU?$_BitInt@$0BM@@__clang@@U?$_BitInt@$0EB@@2@@Z"
491 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32
492 // CHECK: shl i32 10, %[[PROMO]]
494 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32
495 // CHECK: ashr i32 10, %[[PROMO]]
497 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32
498 // CHECK: shl i32 10, %[[PROMO]]
500 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32
501 // CHECK: ashr i32 10, %[[PROMO]]
504 void Shift(_BitInt(28) Ext
, _BitInt(65) LargeExt
, int i
) {
505 // LIN: define{{.*}} void @_Z5ShiftDB28_DB65_
506 // WIN: define dso_local void @"?Shift@@YAXU?$_BitInt@$0BM@@__clang@@U?$_BitInt@$0EB@@2@H@Z"
508 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32
509 // CHECK: shl i32 {{.+}}, %[[PROMO]]
511 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32
512 // CHECK: ashr i32 {{.+}}, %[[PROMO]]
515 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32
516 // CHECK: shl i32 {{.+}}, %[[PROMO]]
518 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32
519 // CHECK: ashr i32 {{.+}}, %[[PROMO]]
522 // CHECK: %[[BI:.+]] = trunc i32 %{{.+}} to i28
523 // CHECK: %[[PROMO:.+]] = trunc i32 %{{.+}} to i28
524 // CHECK: shl i28 %[[BI]], %[[PROMO]]
526 // CHECK: %[[BI:.+]] = trunc i32 %{{.+}} to i28
527 // CHECK: %[[PROMO:.+]] = trunc i32 %{{.+}} to i28
528 // CHECK: ashr i28 %[[BI]], %[[PROMO]]
531 // CHECK: %[[PROMO:.+]] = zext i32 %{{.+}} to i65
532 // CHECK: shl i65 {{.+}}, %[[PROMO]]
534 // CHECK: %[[PROMO:.+]] = zext i32 %{{.+}} to i65
535 // CHECK: ashr i65 {{.+}}, %[[PROMO]]
538 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i28
539 // CHECK: shl i28 {{.+}}, %[[PROMO]]
541 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i28
542 // CHECK: ashr i28 {{.+}}, %[[PROMO]]
545 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i65
546 // CHECK: shl i65 {{.+}}, %[[PROMO]]
548 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i65
549 // CHECK: ashr i65 {{.+}}, %[[PROMO]]
552 typedef _BitInt(64) vint64_t16
__attribute__((vector_size(16)));
553 void VectorTest(vint64_t16 first
, vint64_t16 second
) {
554 // LIN: define{{.*}} void @_Z10VectorTestDv2_DB64_S0_(<2 x i64> %{{.+}}, <2 x i64> %{{.+}})
555 // WIN64: define dso_local void @"?VectorTest@@YAXT?$__vector@U?$_BitInt@$0EA@@__clang@@$01@__clang@@0@Z"(<2 x i64> %{{.+}}, <2 x i64> %{{.+}})
556 // WIN32: define dso_local void @"?VectorTest@@YAXT?$__vector@U?$_BitInt@$0EA@@__clang@@$01@__clang@@0@Z"(<2 x i64> inreg %{{.+}}, <2 x i64> inreg %{{.+}})
557 __builtin_shufflevector (first
, first
, 1, 3, 2) + __builtin_shufflevector (second
, second
, 1, 3, 2);
558 // CHECK: %[[Shuffle:.+]] = shufflevector <2 x i64> %{{.+}}, <2 x i64> %{{.+}}, <3 x i32> <i32 1, i32 3, i32 2>
559 // CHECK: %[[Shuffle1:.+]] = shufflevector <2 x i64> %{{.+}}, <2 x i64> %{{.+}}, <3 x i32> <i32 1, i32 3, i32 2>
560 // CHECK: %[[ADD:.+]] = add <3 x i64> %[[Shuffle]], %[[Shuffle1]]
563 void VectorTest(uint16_t4 first
, uint16_t4 second
) {
564 // LIN64: define{{.*}} void @_Z10VectorTestDv4_DU16_S0_(double %{{.+}}, double %{{.+}})
565 // LIN32: define{{.*}} void @_Z10VectorTestDv4_DU16_S0_(i64 %{{.+}}, i64 %{{.+}})
566 // WIN64: define dso_local void @"?VectorTest@@YAXT?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@0@Z"(<4 x i16> %{{.+}}, <4 x i16> %{{.+}})
567 // WIN32: define dso_local void @"?VectorTest@@YAXT?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@0@Z"(<4 x i16> inreg %{{.+}}, <4 x i16> inreg %{{.+}})
568 first
.xzw
+ second
.zwx
;
569 // CHECK: %[[Shuffle:.+]] = shufflevector <4 x i16> %{{.+}}, <4 x i16> poison, <3 x i32> <i32 0, i32 2, i32 3>
570 // CHECK: %[[Shuffle1:.+]] = shufflevector <4 x i16> %{{.+}}, <4 x i16> poison, <3 x i32> <i32 2, i32 3, i32 0>
571 // CHECK: %[[ADD:.+]] = add <3 x i16> %[[Shuffle]], %[[Shuffle1]]
574 // Ensure that these types don't alias the normal int types.
575 void TBAATest(_BitInt(sizeof(int) * 8) ExtInt
,
576 unsigned _BitInt(sizeof(int) * 8) ExtUInt
,
578 // CHECK-DAG: store i32 %{{.+}}, ptr %{{.+}}, align 4, !tbaa ![[EXTINT_TBAA:.+]]
579 // CHECK-DAG: store i32 %{{.+}}, ptr %{{.+}}, align 4, !tbaa ![[EXTINT_TBAA]]
580 // CHECK-DAG: store i8 %{{.+}}, ptr %{{.+}}, align 1, !tbaa ![[EXTINT6_TBAA:.+]]
586 // NoNewStructPathTBAA-DAG: ![[CHAR_TBAA_ROOT:.+]] = !{!"omnipotent char", ![[TBAA_ROOT:.+]], i64 0}
587 // NoNewStructPathTBAA-DAG: ![[TBAA_ROOT]] = !{!"Simple C++ TBAA"}
588 // NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA]] = !{![[EXTINT_TBAA_ROOT:.+]], ![[EXTINT_TBAA_ROOT]], i64 0}
589 // NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{!"_BitInt(32)", ![[CHAR_TBAA_ROOT]], i64 0}
590 // NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA]] = !{![[EXTINT6_TBAA_ROOT:.+]], ![[EXTINT6_TBAA_ROOT]], i64 0}
591 // NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{!"_BitInt(6)", ![[CHAR_TBAA_ROOT]], i64 0}
593 // NewStructPathTBAA-DAG: ![[CHAR_TBAA_ROOT:.+]] = !{![[TBAA_ROOT:.+]], i64 1, !"omnipotent char"}
594 // NewStructPathTBAA-DAG: ![[TBAA_ROOT]] = !{!"Simple C++ TBAA"}
595 // NewStructPathTBAA-DAG: ![[EXTINT_TBAA]] = !{![[EXTINT_TBAA_ROOT:.+]], ![[EXTINT_TBAA_ROOT]], i64 0, i64 4}
596 // NewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 4, !"_BitInt(32)"}
597 // NewStructPathTBAA-DAG: ![[EXTINT6_TBAA]] = !{![[EXTINT6_TBAA_ROOT:.+]], ![[EXTINT6_TBAA_ROOT]], i64 0, i64 1}
598 // NewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 1, !"_BitInt(6)"}
601 template <int N
> struct S
{
602 using T
= _BitInt(N
);
605 template <int N
> void foo(S
<N
> B
) {
606 const auto Var
= B
.Data
;