1 // REQUIRES: arm-registered-target
2 // RUN: %clang_cc1 -triple aarch64-none-elf \
3 // RUN: -O2 \
4 // RUN: -emit-llvm -fexperimental-max-bitint-width=1024 -o - %s | FileCheck %s
5
6 extern "C" {
7
8 // Base case, nothing interesting.
9 struct S {
10 long x, y;
11 };
12
13 void f0(long, S);
14 void f0m(long, long, long, long, long, S);
g0()15 void g0() {
16 S s = {6, 7};
17 f0(1, s);
18 f0m(1, 2, 3, 4, 5, s);
19 }
20 // CHECK: define{{.*}} void @g0
21 // CHECK: call void @f0(i64 noundef 1, [2 x i64] [i64 6, i64 7]
22 // CHECK: call void @f0m{{.*}}[2 x i64] [i64 6, i64 7]
23 // CHECK: declare void @f0(i64 noundef, [2 x i64])
24 // CHECK: declare void @f0m(i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, [2 x i64])
25
26 // Aligned struct, passed according to its natural alignment.
27 struct __attribute__((aligned(16))) S16 {
28 long x, y;
29 } s16;
30
31 void f1(long, S16);
32 void f1m(long, long, long, long, long, S16);
g1()33 void g1() {
34 S16 s = {6, 7};
35 f1(1, s);
36 f1m(1, 2, 3, 4, 5, s);
37 }
38 // CHECK: define{{.*}} void @g1
39 // CHECK: call void @f1{{.*}}[2 x i64] [i64 6, i64 7]
40 // CHECK: call void @f1m{{.*}}[2 x i64] [i64 6, i64 7]
41 // CHECK: declare void @f1(i64 noundef, [2 x i64])
42 // CHECK: declare void @f1m(i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, [2 x i64])
43
44 // Increased natural alignment.
45 struct SF16 {
46 long x __attribute__((aligned(16)));
47 long y;
48 };
49
50 void f3(long, SF16);
51 void f3m(long, long, long, long, long, SF16);
g3()52 void g3() {
53 SF16 s = {6, 7};
54 f3(1, s);
55 f3m(1, 2, 3, 4, 5, s);
56 }
57 // CHECK: define{{.*}} void @g3
58 // CHECK: call void @f3(i64 noundef 1, i128 129127208515966861318)
59 // CHECK: call void @f3m(i64 noundef 1, i64 noundef 2, i64 noundef 3, i64 noundef 4, i64 noundef 5, i128 129127208515966861318)
60 // CHECK: declare void @f3(i64 noundef, i128)
61 // CHECK: declare void @f3m(i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i128)
62
63
64 // Packed structure.
65 struct __attribute__((packed)) P {
66 int x;
67 long u;
68 };
69
70 void f4(int, P);
71 void f4m(int, int, int, int, int, P);
g4()72 void g4() {
73 P s = {6, 7};
74 f4(1, s);
75 f4m(1, 2, 3, 4, 5, s);
76 }
77 // CHECK: define{{.*}} void @g4()
78 // CHECK: call void @f4(i32 noundef 1, [2 x i64] [i64 30064771078, i64 0])
79 // CHECK: void @f4m(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, [2 x i64] [i64 30064771078, i64 0])
80 // CHECK: declare void @f4(i32 noundef, [2 x i64])
81 // CHECK: declare void @f4m(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, [2 x i64])
82
83
84 // Packed structure, overaligned, same as above.
85 struct __attribute__((packed, aligned(16))) P16 {
86 int x;
87 long y;
88 };
89
90 void f5(int, P16);
91 void f5m(int, int, int, int, int, P16);
g5()92 void g5() {
93 P16 s = {6, 7};
94 f5(1, s);
95 f5m(1, 2, 3, 4, 5, s);
96 }
97 // CHECK: define{{.*}} void @g5()
98 // CHECK: call void @f5(i32 noundef 1, [2 x i64] [i64 30064771078, i64 0])
99 // CHECK: void @f5m(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, [2 x i64] [i64 30064771078, i64 0])
100 // CHECK: declare void @f5(i32 noundef, [2 x i64])
101 // CHECK: declare void @f5m(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, [2 x i64])
102
103 //BitInt alignment
104 struct BITINT129 {
105 char ch;
106 unsigned _BitInt(129) v;
107 };
108
test_bitint129()109 int test_bitint129(){
110 return __builtin_offsetof(struct BITINT129, v);
111 }
112 // CHECK: ret i32 16
113
114 struct BITINT127 {
115 char ch;
116 _BitInt(127) v;
117 };
118
test_bitint127()119 int test_bitint127(){
120 return __builtin_offsetof(struct BITINT127, v);
121 }
122 // CHECK: ret i32 16
123
124 struct BITINT63 {
125 char ch;
126 _BitInt(63) v;
127 };
128
test_bitint63()129 int test_bitint63(){
130 return __builtin_offsetof(struct BITINT63, v);
131 }
132 // CHECK: ret i32 8
133
134 struct BITINT32 {
135 char ch;
136 unsigned _BitInt(32) v;
137 };
138
test_bitint32()139 int test_bitint32(){
140 return __builtin_offsetof(struct BITINT32, v);
141 }
142 // CHECK: ret i32 4
143
144 struct BITINT9 {
145 char ch;
146 unsigned _BitInt(9) v;
147 };
148
test_bitint9()149 int test_bitint9(){
150 return __builtin_offsetof(struct BITINT9, v);
151 }
152 // CHECK: ret i32 2
153
154 struct BITINT8 {
155 char ch;
156 unsigned _BitInt(8) v;
157 };
158
test_bitint8()159 int test_bitint8(){
160 return __builtin_offsetof(struct BITINT8, v);
161 }
162 // CHECK: ret i32 1
163
164 }
165
166