| 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 |
// 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 |
|
| 15 |
//BitInt alignment |
| 16 |
struct BITINT129 { |
| 17 |
char ch; |
| 18 |
unsigned _BitInt(129) v; |
| 19 |
}; |
| 20 |
|
| 21 |
int test_bitint129(){ |
| 22 |
return __builtin_offsetof(struct BITINT129, v); |
| 23 |
} |
| 24 |
// CHECK: ret i32 16 |
| 25 |
|
| 26 |
struct BITINT127 { |
| 27 |
char ch; |
| 28 |
_BitInt(127) v; |
| 29 |
}; |
| 30 |
|
| 31 |
int test_bitint127(){ |
| 32 |
return __builtin_offsetof(struct BITINT127, v); |
| 33 |
} |
| 34 |
// CHECK: ret i32 16 |
| 35 |
|
| 36 |
struct BITINT63 { |
| 37 |
char ch; |
| 38 |
_BitInt(63) v; |
| 39 |
}; |
| 40 |
|
| 41 |
int test_bitint63(){ |
| 42 |
return __builtin_offsetof(struct BITINT63, v); |
| 43 |
} |
| 44 |
// CHECK: ret i32 8 |
| 45 |
|
| 46 |
struct BITINT32 { |
| 47 |
char ch; |
| 48 |
unsigned _BitInt(32) v; |
| 49 |
}; |
| 50 |
|
| 51 |
int test_bitint32(){ |
| 52 |
return __builtin_offsetof(struct BITINT32, v); |
| 53 |
} |
| 54 |
// CHECK: ret i32 4 |
| 55 |
|
| 56 |
struct BITINT9 { |
| 57 |
char ch; |
| 58 |
unsigned _BitInt(9) v; |
| 59 |
}; |
| 60 |
|
| 61 |
int test_bitint9(){ |
| 62 |
return __builtin_offsetof(struct BITINT9, v); |
| 63 |
} |
| 64 |
// CHECK: ret i32 2 |
| 65 |
|
| 66 |
struct BITINT8 { |
| 67 |
char ch; |
| 68 |
unsigned _BitInt(8) v; |
| 69 |
}; |
| 70 |
|
| 71 |
int test_bitint8(){ |
| 72 |
return __builtin_offsetof(struct BITINT8, v); |
| 73 |
} |
| 74 |
// CHECK: ret i32 1 |
| 75 |
|
| 76 |
// Over-sized bitfield, which results in a 64-bit container type, so 64-bit |
| 77 |
// alignment. |
| 78 |
struct OverSizedBitfield { |
| 79 |
int x : 64; |
| 80 |
}; |
| 81 |
|
| 82 |
unsigned sizeof_OverSizedBitfield = sizeof(OverSizedBitfield); |
| 83 |
unsigned alignof_OverSizedBitfield = alignof(OverSizedBitfield); |
| 84 |
|
| 85 |
// CHECK: define{{.*}} void @g7 |
| 86 |
// CHECK: call void @f7(i32 noundef 1, i64 42) |
| 87 |
// CHECK: declare void @f7(i32 noundef, i64) |
| 88 |
void f7(int a, OverSizedBitfield b); |
| 89 |
void g7() { |
| 90 |
OverSizedBitfield s = {42}; |
| 91 |
f7(1, s); |
| 92 |
} |
| 93 |
|
| 94 |
// AAPCS64 does have a 128-bit integer fundamental data type, so this gets a |
| 95 |
// 128-bit container with 128-bit alignment. This is just within the limit of |
| 96 |
// what can be passed directly. |
| 97 |
struct VeryOverSizedBitfield { |
| 98 |
int x : 128; |
| 99 |
}; |
| 100 |
|
| 101 |
unsigned sizeof_VeryOverSizedBitfield = sizeof(VeryOverSizedBitfield); |
| 102 |
unsigned alignof_VeryOverSizedBitfield = alignof(VeryOverSizedBitfield); |
| 103 |
|
| 104 |
// CHECK: define{{.*}} void @g8 |
| 105 |
// CHECK: call void @f8(i32 noundef 1, i128 42) |
| 106 |
// CHECK: declare void @f8(i32 noundef, i128) |
| 107 |
void f8(int a, VeryOverSizedBitfield b); |
| 108 |
void g8() { |
| 109 |
VeryOverSizedBitfield s = {42}; |
| 110 |
f8(1, s); |
| 111 |
} |
| 112 |
|
| 113 |
// There are no bigger fundamental data types, so this gets a 128-bit container |
| 114 |
// and 128 bits of padding, giving the struct a size of 32 bytes, and an |
| 115 |
// alignment of 16 bytes. This is over the PCS size limit of 16 bytes, so it |
| 116 |
// will be passed indirectly. |
| 117 |
struct RidiculouslyOverSizedBitfield { |
| 118 |
int x : 256; |
| 119 |
}; |
| 120 |
|
| 121 |
unsigned sizeof_RidiculouslyOverSizedBitfield = sizeof(RidiculouslyOverSizedBitfield); |
| 122 |
unsigned alignof_RidiculouslyOverSizedBitfield = alignof(RidiculouslyOverSizedBitfield); |
| 123 |
|
| 124 |
// CHECK: define{{.*}} void @g9 |
| 125 |
// CHECK: call void @f9(i32 noundef 1, ptr dead_on_return noundef nonnull %agg.tmp) |
| 126 |
// CHECK: declare void @f9(i32 noundef, ptr dead_on_return noundef) |
| 127 |
void f9(int a, RidiculouslyOverSizedBitfield b); |
| 128 |
void g9() { |
| 129 |
RidiculouslyOverSizedBitfield s = {42}; |
| 130 |
f9(1, s); |
| 131 |
} |
| 132 |
|
| 133 |
} |
| 134 |
|