1 // RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK64
2 // RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK64
3 // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN32
4 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN32
7 unsigned _BitInt(1) GlobSize1
= 0;
8 // CHECK: @GlobSize1 = {{.*}}global i1 false
10 void GenericTest(_BitInt(3) a
, unsigned _BitInt(3) b
, _BitInt(4) c
) {
11 // CHECK: define {{.*}}void @GenericTest
12 int which
= _Generic(a
, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3);
14 int which2
= _Generic(b
, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3);
16 int which3
= _Generic(c
, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3);
20 void VLATest(_BitInt(3) A
, _BitInt(99) B
, _BitInt(123) C
) {
21 // CHECK: define {{.*}}void @VLATest
23 // CHECK: %[[A:.+]] = zext i3 %{{.+}} to i[[INDXSIZE:[0-9]+]]
24 // CHECK: %[[VLA1:.+]] = alloca i32, i[[INDXSIZE]] %[[A]]
26 // CHECK: %[[B:.+]] = trunc i99 %{{.+}} to i[[INDXSIZE]]
27 // CHECK: %[[VLA2:.+]] = alloca i32, i[[INDXSIZE]] %[[B]]
29 // CHECK: %[[C:.+]] = trunc i123 %{{.+}} to i[[INDXSIZE]]
30 // CHECK: %[[VLA3:.+]] = alloca i32, i[[INDXSIZE]] %[[C]]
39 void OffsetOfTest(void) {
40 // CHECK: define {{.*}}void @OffsetOfTest
41 int A
= __builtin_offsetof(struct S
,A
);
42 // CHECK: store i32 0, ptr %{{.+}}
43 int B
= __builtin_offsetof(struct S
,B
);
44 // CHECK64: store i32 8, ptr %{{.+}}
45 // LIN32: store i32 4, ptr %{{.+}}
46 // WINCHECK32: store i32 8, ptr %{{.+}}
47 int C
= __builtin_offsetof(struct S
,C
);
48 // CHECK64: store i32 24, ptr %{{.+}}
49 // LIN32: store i32 20, ptr %{{.+}}
50 // WIN32: store i32 24, ptr %{{.+}}
53 void Size1ExtIntParam(unsigned _BitInt(1) A
) {
54 // CHECK: define {{.*}}void @Size1ExtIntParam(i1{{.*}} %[[PARAM:.+]])
55 // CHECK: %[[PARAM_ADDR:.+]] = alloca i1
56 // CHECK: %[[B:.+]] = alloca [5 x i1]
57 // CHECK: store i1 %[[PARAM]], ptr %[[PARAM_ADDR]]
58 unsigned _BitInt(1) B
[5];
60 // CHECK: %[[PARAM_LOAD:.+]] = load i1, ptr %[[PARAM_ADDR]]
61 // CHECK: %[[IDX:.+]] = getelementptr inbounds [5 x i1], ptr %[[B]]
62 // CHECK: store i1 %[[PARAM_LOAD]], ptr %[[IDX]]