Skip to content

Commit 01b4a28

Browse files
committed
[ARM,AArch64] Over-sized bitfields affect unadjusted alignment
The container type picked for an over-sized bitfield already contributes to the alignment of the structure, but it should also contribute to the "unadjusted alignment" which is used by the ARM and AArch64 PCS.
1 parent 75e6e37 commit 01b4a28

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

clang/lib/AST/RecordLayoutBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,7 @@ void ItaniumRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize,
15231523
setSize(std::max(getSizeInBits(), getDataSizeInBits()));
15241524

15251525
// Remember max struct/class alignment.
1526+
UnadjustedAlignment = std::max(UnadjustedAlignment, TypeAlign);
15261527
UpdateAlignment(TypeAlign);
15271528
}
15281529

clang/test/CodeGen/aapcs-align.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ unsigned sizeof_OverSizedBitfield = sizeof(OverSizedBitfield);
154154
unsigned alignof_OverSizedBitfield = alignof(OverSizedBitfield);
155155

156156
// CHECK: define{{.*}} void @g7
157-
// CHECK: call void @f7(i32 noundef 1, [2 x i32] [i32 42, i32 0])
158-
// CHECK: declare void @f7(i32 noundef, [2 x i32])
157+
// CHECK: call void @f7(i32 noundef 1, [1 x i64] [i64 42])
158+
// CHECK: declare void @f7(i32 noundef, [1 x i64])
159159
void f7(int a, OverSizedBitfield b);
160160
void g7() {
161161
OverSizedBitfield s = {42};
@@ -173,8 +173,8 @@ unsigned sizeof_VeryOverSizedBitfield = sizeof(VeryOverSizedBitfield);
173173
unsigned alignof_VeryOverSizedBitfield = alignof(VeryOverSizedBitfield);
174174

175175
// CHECK: define{{.*}} void @g8
176-
// CHECK: call void @f8(i32 noundef 1, [4 x i32] [i32 42, i32 0, i32 0, i32 0])
177-
// CHECK: declare void @f8(i32 noundef, [4 x i32])
176+
// CHECK: call void @f8(i32 noundef 1, [2 x i64] [i64 42, i64 0])
177+
// CHECK: declare void @f8(i32 noundef, [2 x i64])
178178
void f8(int a, VeryOverSizedBitfield b);
179179
void g8() {
180180
VeryOverSizedBitfield s = {42};

clang/test/CodeGen/aapcs64-align.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ unsigned sizeof_VeryOverSizedBitfield = sizeof(VeryOverSizedBitfield);
197197
unsigned alignof_VeryOverSizedBitfield = alignof(VeryOverSizedBitfield);
198198

199199
// CHECK: define{{.*}} void @g8
200-
// CHECK: call void @f8(i32 noundef 1, [2 x i64] [i64 42, i64 0])
201-
// CHECK: declare void @f8(i32 noundef, [2 x i64])
200+
// CHECK: call void @f8(i32 noundef 1, i128 42)
201+
// CHECK: declare void @f8(i32 noundef, i128)
202202
void f8(int a, VeryOverSizedBitfield b);
203203
void g8() {
204204
VeryOverSizedBitfield s = {42};

0 commit comments

Comments
 (0)