|
5 | 5 |
|
6 | 6 | extern "C" { |
7 | 7 |
|
| 8 | +// CHECK: @sizeof_OverSizedBitfield ={{.*}} global i32 8 |
| 9 | +// CHECK: @alignof_OverSizedBitfield ={{.*}} global i32 8 |
| 10 | +// CHECK: @sizeof_VeryOverSizedBitfield ={{.*}} global i32 16 |
| 11 | +// CHECK: @alignof_VeryOverSizedBitfield ={{.*}} global i32 16 |
| 12 | +// CHECK: @sizeof_RidiculouslyOverSizedBitfield ={{.*}} global i32 32 |
| 13 | +// CHECK: @alignof_RidiculouslyOverSizedBitfield ={{.*}} global i32 16 |
| 14 | + |
8 | 15 | // Base case, nothing interesting. |
9 | 16 | struct S { |
10 | 17 | long x, y; |
@@ -161,5 +168,62 @@ int test_bitint8(){ |
161 | 168 | } |
162 | 169 | // CHECK: ret i32 1 |
163 | 170 |
|
| 171 | +// Over-sized bitfield, which results in a 64-bit container type, so 64-bit |
| 172 | +// alignment. |
| 173 | +struct OverSizedBitfield { |
| 174 | + int x : 64; |
| 175 | +}; |
| 176 | + |
| 177 | +unsigned sizeof_OverSizedBitfield = sizeof(OverSizedBitfield); |
| 178 | +unsigned alignof_OverSizedBitfield = alignof(OverSizedBitfield); |
| 179 | + |
| 180 | +// CHECK: define{{.*}} void @g7 |
| 181 | +// CHECK: call void @f7(i32 noundef 1, i64 42) |
| 182 | +// CHECK: declare void @f7(i32 noundef, i64) |
| 183 | +void f7(int a, OverSizedBitfield b); |
| 184 | +void g7() { |
| 185 | + OverSizedBitfield s = {42}; |
| 186 | + f7(1, s); |
| 187 | +} |
| 188 | + |
| 189 | +// AAPCS64 does have a 128-bit integer fundamental data type, so this gets a |
| 190 | +// 128-bit container with 128-bit alignment. This is just within the limit of |
| 191 | +// what can be passed directly. |
| 192 | +struct VeryOverSizedBitfield { |
| 193 | + int x : 128; |
| 194 | +}; |
| 195 | + |
| 196 | +unsigned sizeof_VeryOverSizedBitfield = sizeof(VeryOverSizedBitfield); |
| 197 | +unsigned alignof_VeryOverSizedBitfield = alignof(VeryOverSizedBitfield); |
| 198 | + |
| 199 | +// CHECK: define{{.*}} void @g8 |
| 200 | +// CHECK: call void @f8(i32 noundef 1, i128 42) |
| 201 | +// CHECK: declare void @f8(i32 noundef, i128) |
| 202 | +void f8(int a, VeryOverSizedBitfield b); |
| 203 | +void g8() { |
| 204 | + VeryOverSizedBitfield s = {42}; |
| 205 | + f8(1, s); |
| 206 | +} |
| 207 | + |
| 208 | +// There are no bigger fundamental data types, so this gets a 128-bit container |
| 209 | +// and 128 bits of padding, giving the struct a size of 32 bytes, and an |
| 210 | +// alignment of 16 bytes. This is over the PCS size limit of 16 bytes, so it |
| 211 | +// will be passed indirectly. |
| 212 | +struct RidiculouslyOverSizedBitfield { |
| 213 | + int x : 256; |
| 214 | +}; |
| 215 | + |
| 216 | +unsigned sizeof_RidiculouslyOverSizedBitfield = sizeof(RidiculouslyOverSizedBitfield); |
| 217 | +unsigned alignof_RidiculouslyOverSizedBitfield = alignof(RidiculouslyOverSizedBitfield); |
| 218 | + |
| 219 | +// CHECK: define{{.*}} void @g9 |
| 220 | +// CHECK: call void @f9(i32 noundef 1, ptr noundef nonnull %agg.tmp) |
| 221 | +// CHECK: declare void @f9(i32 noundef, ptr noundef) |
| 222 | +void f9(int a, RidiculouslyOverSizedBitfield b); |
| 223 | +void g9() { |
| 224 | + RidiculouslyOverSizedBitfield s = {42}; |
| 225 | + f9(1, s); |
| 226 | +} |
| 227 | + |
164 | 228 | } |
165 | 229 |
|
0 commit comments