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 { i35, i32 }
57 struct HasBitIntLast
{
61 // CHECK: %struct.HasBitIntLast = type { i32, i35 }
63 struct HasBitIntMiddle
{
68 // CHECK: %struct.HasBitIntMiddle = type { i32, i35, 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(ptr %[[STARTAD]])
163 // LIN32: call void @llvm.va_start(ptr %[[ARGS]])
164 // WIN: call void @llvm.va_start(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 %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 i92, ptr %[[BC1]]
174 // LIN64: store i92 %[[LOAD1]], ptr
176 // LIN32: %[[CUR1:.+]] = load ptr, ptr %[[ARGS]]
177 // LIN32: %[[NEXT1:.+]] = getelementptr inbounds i8, ptr %[[CUR1]], i32 12
178 // LIN32: store ptr %[[NEXT1]], ptr %[[ARGS]]
179 // LIN32: %[[LOADV1:.+]] = load i92, ptr %[[CUR1]]
180 // LIN32: store i92 %[[LOADV1]], ptr
182 // WIN64: %[[CUR1:.+]] = load ptr, ptr %[[ARGS]]
183 // WIN64: %[[NEXT1:.+]] = getelementptr inbounds i8, ptr %[[CUR1]], i64 8
184 // WIN64: store ptr %[[NEXT1]], ptr %[[ARGS]]
185 // WIN64: %[[LOADP1:.+]] = load ptr, ptr %[[CUR1]]
186 // WIN64: %[[LOADV1:.+]] = load i92, ptr %[[LOADP1]]
187 // WIN64: store i92 %[[LOADV1]], ptr
189 // WIN32: %[[CUR1:.+]] = load ptr, ptr %[[ARGS]]
190 // WIN32: %[[NEXT1:.+]] = getelementptr inbounds i8, ptr %[[CUR1]], i32 16
191 // WIN32: store ptr %[[NEXT1]], ptr %[[ARGS]]
192 // WIN32: %[[LOADV1:.+]] = load i92, ptr %[[CUR1]]
193 // WIN32: store i92 %[[LOADV1]], ptr
196 _BitInt(31) B
= __builtin_va_arg(args
, _BitInt(31));
197 // LIN64: %[[AD2:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
198 // LIN64: %[[OFA_P2:.+]] = getelementptr inbounds %struct.__va_list_tag, ptr %[[AD2]], i32 0, i32 0
199 // LIN64: %[[GPOFFSET:.+]] = load i32, ptr %[[OFA_P2]]
200 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 40
201 // LIN64: br i1 %[[FITSINGP]]
202 // LIN64: %[[BC1:.+]] = phi ptr
203 // LIN64: %[[LOAD1:.+]] = load i31, ptr %[[BC1]]
204 // LIN64: store i31 %[[LOAD1]], ptr
206 // LIN32: %[[CUR2:.+]] = load ptr, ptr %[[ARGS]]
207 // LIN32: %[[NEXT2:.+]] = getelementptr inbounds i8, ptr %[[CUR2]], i32 4
208 // LIN32: store ptr %[[NEXT2]], ptr %[[ARGS]]
209 // LIN32: %[[LOADV2:.+]] = load i31, ptr %[[CUR2]]
210 // LIN32: store i31 %[[LOADV2]], ptr
212 // WIN64: %[[CUR2:.+]] = load ptr, ptr %[[ARGS]]
213 // WIN64: %[[NEXT2:.+]] = getelementptr inbounds i8, ptr %[[CUR2]], i64 8
214 // WIN64: store ptr %[[NEXT2]], ptr %[[ARGS]]
215 // WIN64: %[[LOADV2:.+]] = load i31, ptr %[[CUR2]]
216 // WIN64: store i31 %[[LOADV2]], ptr
218 // WIN32: %[[CUR2:.+]] = load ptr, ptr %[[ARGS]]
219 // WIN32: %[[NEXT2:.+]] = getelementptr inbounds i8, ptr %[[CUR2]], i32 4
220 // WIN32: store ptr %[[NEXT2]], ptr %[[ARGS]]
221 // WIN32: %[[LOADV2:.+]] = load i31, ptr %[[CUR2]]
222 // WIN32: store i31 %[[LOADV2]], ptr
224 _BitInt(16) C
= __builtin_va_arg(args
, _BitInt(16));
225 // LIN64: %[[AD3:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
226 // LIN64: %[[OFA_P3:.+]] = getelementptr inbounds %struct.__va_list_tag, ptr %[[AD3]], i32 0, i32 0
227 // LIN64: %[[GPOFFSET:.+]] = load i32, ptr %[[OFA_P3]]
228 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 40
229 // LIN64: br i1 %[[FITSINGP]]
230 // LIN64: %[[BC1:.+]] = phi ptr
231 // LIN64: %[[LOAD1:.+]] = load i16, ptr %[[BC1]]
232 // LIN64: store i16 %[[LOAD1]], ptr
234 // LIN32: %[[CUR3:.+]] = load ptr, ptr %[[ARGS]]
235 // LIN32: %[[NEXT3:.+]] = getelementptr inbounds i8, ptr %[[CUR3]], i32 4
236 // LIN32: store ptr %[[NEXT3]], ptr %[[ARGS]]
237 // LIN32: %[[LOADV3:.+]] = load i16, ptr %[[CUR3]]
238 // LIN32: store i16 %[[LOADV3]], ptr
240 // WIN64: %[[CUR3:.+]] = load ptr, ptr %[[ARGS]]
241 // WIN64: %[[NEXT3:.+]] = getelementptr inbounds i8, ptr %[[CUR3]], i64 8
242 // WIN64: store ptr %[[NEXT3]], ptr %[[ARGS]]
243 // WIN64: %[[LOADV3:.+]] = load i16, ptr %[[CUR3]]
244 // WIN64: store i16 %[[LOADV3]], ptr
246 // WIN32: %[[CUR3:.+]] = load ptr, ptr %[[ARGS]]
247 // WIN32: %[[NEXT3:.+]] = getelementptr inbounds i8, ptr %[[CUR3]], i32 4
248 // WIN32: store ptr %[[NEXT3]], ptr %[[ARGS]]
249 // WIN32: %[[LOADV3:.+]] = load i16, ptr %[[CUR3]]
250 // WIN32: store i16 %[[LOADV3]], ptr
252 uint16_t4 D
= __builtin_va_arg(args
, uint16_t4
);
253 // LIN64: %[[AD4:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
254 // LIN64: %[[OFA_P4:.+]] = getelementptr inbounds %struct.__va_list_tag, ptr %[[AD4]], i32 0, i32 1
255 // LIN64: %[[GPOFFSET:.+]] = load i32, ptr %[[OFA_P4]]
256 // LIN64: %[[FITSINGP:.+]] = icmp ule i32 %[[GPOFFSET]], 160
257 // LIN64: br i1 %[[FITSINGP]]
258 // LIN64: %[[BC4:.+]] = phi ptr
259 // LIN64: %[[LOADV4:.+]] = load <4 x i16>, ptr %[[BC4]]
260 // LIN64: store <4 x i16> %[[LOADV4]], ptr
262 // LIN32: %[[CUR4:.+]] = load ptr, ptr %[[ARGS]]
263 // LIN32: %[[NEXT4:.+]] = getelementptr inbounds i8, ptr %[[CUR4]], i32 8
264 // LIN32: store ptr %[[NEXT4]], ptr %[[ARGS]]
265 // LIN32: %[[LOADV4:.+]] = load <4 x i16>, ptr %[[CUR4]]
266 // LIN32: store <4 x i16> %[[LOADV4]], ptr %
268 // WIN: %[[CUR4:.+]] = load ptr, ptr %[[ARGS]]
269 // WIN64: %[[NEXT4:.+]] = getelementptr inbounds i8, ptr %[[CUR4]], i64 8
270 // WIN32: %[[NEXT4:.+]] = getelementptr inbounds i8, ptr %[[CUR4]], i32 8
271 // WIN: store ptr %[[NEXT4]], ptr %[[ARGS]]
272 // WIN: %[[LOADV4:.+]] = load <4 x i16>, ptr %[[CUR4]]
273 // WIN: store <4 x i16> %[[LOADV4]], ptr
275 vint32_t8 E
= __builtin_va_arg(args
, vint32_t8
);
276 // LIN64: %[[AD5:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
277 // LIN64: %[[OFAA_P4:.+]] = getelementptr inbounds %struct.__va_list_tag, ptr %[[AD5]], i32 0, i32 2
278 // LIN64: %[[OFAA:.+]] = load ptr, ptr %[[OFAA_P4]]
280 // LIN64: [[OFAA_GEP:%.*]] = getelementptr inbounds i8, ptr %[[OFAA]], i32 31
281 // LIN64: %[[OFAA_ALIGNED:.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[OFAA_GEP]], i64 -32)
282 // LIN64: %[[LOADV5:.+]] = load <8 x i32>, ptr %[[OFAA_ALIGNED]]
283 // LIN64: store <8 x i32> %[[LOADV5]], ptr
285 // LIN32: %[[CUR5:.+]] = load ptr, ptr %[[ARGS]]
287 // LIN32: [[GEP_CUR5:%.*]] = getelementptr inbounds i8, ptr %[[CUR5]], i32 31
288 // LIN32: %[[CUR5_ALIGNED:.*]] = call ptr @llvm.ptrmask.p0.i32(ptr [[GEP_CUR5]], i32 -32)
289 // LIN32: %[[NEXT5:.+]] = getelementptr inbounds i8, ptr %[[CUR5_ALIGNED]], i32 32
290 // LIN32: store ptr %[[NEXT5]], ptr %[[ARGS]]
291 // LIN32: %[[LOADV5:.+]] = load <8 x i32>, ptr %[[CUR5_ALIGNED]]
292 // LIN32: store <8 x i32> %[[LOADV5]], ptr
294 // WIN: %[[CUR5:.+]] = load ptr, ptr %[[ARGS]]
295 // WIN64: %[[NEXT5:.+]] = getelementptr inbounds i8, ptr %[[CUR5]], i64 8
296 // WIN32: %[[NEXT5:.+]] = getelementptr inbounds i8, ptr %[[CUR5]], i32 32
297 // WIN: store ptr %[[NEXT5]], ptr %[[ARGS]]
298 // WIN64: %[[LOADP5:.+]] = load ptr, ptr %[[CUR5]]
299 // WIN64: %[[LOADV5:.+]] = load <8 x i32>, ptr %[[LOADP5]]
300 // WIN32: %[[LOADV5:.+]] = load <8 x i32>, ptr %argp.cur7
301 // WIN: store <8 x i32> %[[LOADV5]], ptr
303 __builtin_va_end(args
);
304 // LIN64: %[[ENDAD:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %[[ARGS]]
305 // LIN64: call void @llvm.va_end(ptr %[[ENDAD]])
306 // LIN32: call void @llvm.va_end(ptr %[[ARGS]])
307 // WIN: call void @llvm.va_end(ptr %[[ARGS]])
309 void typeid_tests() {
310 // LIN: define{{.*}} void @_Z12typeid_testsv()
311 // WIN: define dso_local void @"?typeid_tests@@YAXXZ"()
312 unsigned _BitInt(33) U33_1
, U33_2
;
313 _BitInt(33) S33_1
, S33_2
;
314 _BitInt(32) S32_1
, S32_2
;
316 auto A
= typeid(U33_1
);
317 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDU33_)
318 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDU33_)
319 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_UBitInt@$0CB@@__clang@@@8")
320 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_UBitInt@$0CB@@__clang@@@8")
321 auto B
= typeid(U33_2
);
322 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDU33_)
323 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDU33_)
324 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_UBitInt@$0CB@@__clang@@@8")
325 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_UBitInt@$0CB@@__clang@@@8")
326 auto C
= typeid(S33_1
);
327 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDB33_)
328 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDB33_)
329 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_BitInt@$0CB@@__clang@@@8")
330 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_BitInt@$0CB@@__clang@@@8")
331 auto D
= typeid(S33_2
);
332 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDB33_)
333 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDB33_)
334 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_BitInt@$0CB@@__clang@@@8")
335 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_BitInt@$0CB@@__clang@@@8")
336 auto E
= typeid(S32_1
);
337 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDB32_)
338 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDB32_)
339 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_BitInt@$0CA@@__clang@@@8")
340 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_BitInt@$0CA@@__clang@@@8")
341 auto F
= typeid(S32_2
);
342 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDB32_)
343 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDB32_)
344 // WIN64: call ptr @"??0type_info@std@@QEAA@AEBV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @"??_R0U?$_BitInt@$0CA@@__clang@@@8")
345 // WIN32: call x86_thiscallcc ptr @"??0type_info@std@@QAE@ABV01@@Z"(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @"??_R0U?$_BitInt@$0CA@@__clang@@@8")
346 auto G
= typeid(uint16_t4
);
347 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDv4_DU16_)
348 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDv4_DU16_)
349 // 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")
350 // 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")
351 auto H
= typeid(vint32_t8
);
352 // LIN64: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 8 dereferenceable(16) @_ZTIDv8_DB32_)
353 // LIN32: call void @_ZNSt9type_infoC1ERKS_(ptr {{[^,]*}} %{{.+}}, ptr nonnull align 4 dereferenceable(8) @_ZTIDv8_DB32_)
354 // 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")
355 // 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")
358 void ExplicitCasts() {
359 // LIN: define{{.*}} void @_Z13ExplicitCastsv()
360 // WIN: define dso_local void @"?ExplicitCasts@@YAXXZ"()
367 // CHECK: %[[CONV:.+]] = sext i32 %{{.+}} to i33
369 // CHECK: %[[CONV:.+]] = trunc i32 %{{.+}} to i31
371 // CHECK: %[[CONV:.+]] = trunc i33 %{{.+}} to i32
373 // CHECK: %[[CONV:.+]] = sext i31 %{{.+}} to i32
376 // CHECK: %[[CONV:.+]] = trunc i32 %{{.+}} to i16
377 // CHECK: %[[VEC:.+]] = insertelement <4 x i16> poison, i16 %[[CONV]], i64 0
378 // CHECK: %[[Splat:.+]] = shufflevector <4 x i16> %[[VEC]], <4 x i16> poison, <4 x i32> zeroinitializer
389 void OffsetOfTest() {
390 // LIN: define{{.*}} void @_Z12OffsetOfTestv()
391 // WIN: define dso_local void @"?OffsetOfTest@@YAXXZ"()
393 auto A
= __builtin_offsetof(S
,A
);
394 // CHECK: store i{{.+}} 0, ptr %{{.+}}
395 auto B
= __builtin_offsetof(S
,B
);
396 // LIN64: store i{{.+}} 8, ptr %{{.+}}
397 // LIN32: store i{{.+}} 4, ptr %{{.+}}
398 // WIN: store i{{.+}} 8, ptr %{{.+}}
399 auto C
= __builtin_offsetof(S
,C
);
400 // LIN64: store i{{.+}} 24, ptr %{{.+}}
401 // LIN32: store i{{.+}} 20, ptr %{{.+}}
402 // WIN: store i{{.+}} 24, ptr %{{.+}}
403 auto D
= __builtin_offsetof(S
,D
);
404 // LIN64: store i64 32, ptr %{{.+}}
405 // LIN32: store i32 24, ptr %{{.+}}
406 // WIN: store i{{.+}} 32, ptr %{{.+}}
407 auto E
= __builtin_offsetof(S
,E
);
408 // LIN64: store i64 64, ptr %{{.+}}
409 // LIN32: store i32 32, ptr %{{.+}}
410 // WIN: store i{{.+}} 64, ptr %{{.+}}
414 void ShiftBitIntByConstant(_BitInt(28) Ext
) {
415 // LIN: define{{.*}} void @_Z21ShiftBitIntByConstantDB28_
416 // WIN: define dso_local void @"?ShiftBitIntByConstant@@YAXU?$_BitInt@$0BM@@__clang@@@Z"
418 // CHECK: shl i28 %{{.+}}, 7
420 // CHECK: ashr i28 %{{.+}}, 7
422 // CHECK: shl i28 %{{.+}}, -7
424 // CHECK: ashr i28 %{{.+}}, -7
426 // UB in C/C++, Defined in OpenCL.
428 // CHECK: shl i28 %{{.+}}, 29
430 // CHECK: ashr i28 %{{.+}}, 29
432 void ShiftBitIntByConstant(uint16_t4 Ext
) {
433 // LIN64: define{{.*}} void @_Z21ShiftBitIntByConstantDv4_DU16_(double %
434 // LIN32: define dso_local void @_Z21ShiftBitIntByConstantDv4_DU16_(i64 %
435 // WIN: define dso_local void @"?ShiftBitIntByConstant@@YAXT?$__vector@U?$_UBitInt@$0BA@@__clang@@$03@__clang@@@Z"(<4 x i16>
437 // CHECK: shl <4 x i16> %{{.+}}, <i16 7, i16 7, i16 7, i16 7>
439 // CHECK: lshr <4 x i16> %{{.+}}, <i16 7, i16 7, i16 7, i16 7>
441 // CHECK: shl <4 x i16> %{{.+}}, <i16 -7, i16 -7, i16 -7, i16 -7>
443 // CHECK: lshr <4 x i16> %{{.+}}, <i16 -7, i16 -7, i16 -7, i16 -7>
445 // UB in C/C++, Defined in OpenCL.
447 // CHECK: shl <4 x i16> %{{.+}}, <i16 29, i16 29, i16 29, i16 29>
449 // CHECK: lshr <4 x i16> %{{.+}}, <i16 29, i16 29, i16 29, i16 29>
451 void ShiftBitIntByConstant(vint32_t8 Ext
) {
452 // LIN64: define{{.*}} void @_Z21ShiftBitIntByConstantDv8_DB32_(ptr byval(<8 x i32>) align 32 %
453 // LIN32: define dso_local void @_Z21ShiftBitIntByConstantDv8_DB32_(<8 x i32> %
454 // WIN: define dso_local void @"?ShiftBitIntByConstant@@YAXT?$__vector@U?$_BitInt@$0CA@@__clang@@$07@__clang@@@Z"(<8 x i32>
456 // CHECK: shl <8 x i32> %{{.+}}, <i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7>
458 // CHECK: ashr <8 x i32> %{{.+}}, <i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7>
460 // CHECK: shl <8 x i32> %{{.+}}, <i32 -7, i32 -7, i32 -7, i32 -7, i32 -7, i32 -7, i32 -7, i32 -7>
462 // CHECK: ashr <8 x i32> %{{.+}}, <i32 -7, i32 -7, i32 -7, i32 -7, i32 -7, i32 -7, i32 -7, i32 -7>
464 // UB in C/C++, Defined in OpenCL.
466 // CHECK: shl <8 x i32> %{{.+}}, <i32 29, i32 29, i32 29, i32 29, i32 29, i32 29, i32 29, i32 29>
468 // CHECK: ashr <8 x i32> %{{.+}}, <i32 29, i32 29, i32 29, i32 29, i32 29, i32 29, i32 29, i32 29>
471 void ConstantShiftByBitInt(_BitInt(28) Ext
, _BitInt(65) LargeExt
) {
472 // LIN: define{{.*}} void @_Z21ConstantShiftByBitIntDB28_DB65_
473 // WIN: define dso_local void @"?ConstantShiftByBitInt@@YAXU?$_BitInt@$0BM@@__clang@@U?$_BitInt@$0EB@@2@@Z"
475 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32
476 // CHECK: shl i32 10, %[[PROMO]]
478 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32
479 // CHECK: ashr i32 10, %[[PROMO]]
481 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32
482 // CHECK: shl i32 10, %[[PROMO]]
484 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32
485 // CHECK: ashr i32 10, %[[PROMO]]
488 void Shift(_BitInt(28) Ext
, _BitInt(65) LargeExt
, int i
) {
489 // LIN: define{{.*}} void @_Z5ShiftDB28_DB65_
490 // WIN: define dso_local void @"?Shift@@YAXU?$_BitInt@$0BM@@__clang@@U?$_BitInt@$0EB@@2@H@Z"
492 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32
493 // CHECK: shl i32 {{.+}}, %[[PROMO]]
495 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32
496 // CHECK: ashr i32 {{.+}}, %[[PROMO]]
499 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32
500 // CHECK: shl i32 {{.+}}, %[[PROMO]]
502 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i32
503 // CHECK: ashr i32 {{.+}}, %[[PROMO]]
506 // CHECK: %[[PROMO:.+]] = trunc i32 %{{.+}} to i28
507 // CHECK: shl i28 {{.+}}, %[[PROMO]]
509 // CHECK: %[[PROMO:.+]] = trunc i32 %{{.+}} to i28
510 // CHECK: ashr i28 {{.+}}, %[[PROMO]]
513 // CHECK: %[[PROMO:.+]] = zext i32 %{{.+}} to i65
514 // CHECK: shl i65 {{.+}}, %[[PROMO]]
516 // CHECK: %[[PROMO:.+]] = zext i32 %{{.+}} to i65
517 // CHECK: ashr i65 {{.+}}, %[[PROMO]]
520 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i28
521 // CHECK: shl i28 {{.+}}, %[[PROMO]]
523 // CHECK: %[[PROMO:.+]] = trunc i65 %{{.+}} to i28
524 // CHECK: ashr i28 {{.+}}, %[[PROMO]]
527 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i65
528 // CHECK: shl i65 {{.+}}, %[[PROMO]]
530 // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i65
531 // CHECK: ashr i65 {{.+}}, %[[PROMO]]
534 void ComplexTest(_Complex
_BitInt(12) first
, _Complex
_BitInt(33) second
) {
535 // LIN: define{{.*}} void @_Z11ComplexTestCDB12_CDB33_
536 // WIN: define dso_local void @"?ComplexTest@@YAXU?$_Complex@U?$_BitInt@$0M@@__clang@@@__clang@@U?$_Complex@U?$_BitInt@$0CB@@__clang@@@2@@Z"
538 // CHECK: %[[FIRST_REALP:.+]] = getelementptr inbounds { i12, i12 }, ptr %{{.+}}, i32 0, i32 0
539 // CHECK: %[[FIRST_REAL:.+]] = load i12, ptr %[[FIRST_REALP]]
540 // CHECK: %[[FIRST_IMAGP:.+]] = getelementptr inbounds { i12, i12 }, ptr %{{.+}}, i32 0, i32 1
541 // CHECK: %[[FIRST_IMAG:.+]] = load i12, ptr %[[FIRST_IMAGP]]
542 // CHECK: %[[FIRST_REAL_CONV:.+]] = sext i12 %[[FIRST_REAL]]
543 // CHECK: %[[FIRST_IMAG_CONV:.+]] = sext i12 %[[FIRST_IMAG]]
544 // CHECK: %[[SECOND_REALP:.+]] = getelementptr inbounds { i33, i33 }, ptr %{{.+}}, i32 0, i32 0
545 // CHECK: %[[SECOND_REAL:.+]] = load i33, ptr %[[SECOND_REALP]]
546 // CHECK: %[[SECOND_IMAGP:.+]] = getelementptr inbounds { i33, i33 }, ptr %{{.+}}, i32 0, i32 1
547 // CHECK: %[[SECOND_IMAG:.+]] = load i33, ptr %[[SECOND_IMAGP]]
548 // CHECK: %[[REAL:.+]] = add i33 %[[FIRST_REAL_CONV]], %[[SECOND_REAL]]
549 // CHECK: %[[IMAG:.+]] = add i33 %[[FIRST_IMAG_CONV]], %[[SECOND_IMAG]]
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 i6 %{{.+}}, 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)"}