Skip to content

Commit 9ab483f

Browse files
committed
[clang] Remove class layout scissor
1 parent f52ca63 commit 9ab483f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

clang/lib/CodeGen/CGRecordLayoutBuilder.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct CGRecordLowering {
7575
// sentinel member type that ensures correct rounding.
7676
struct MemberInfo {
7777
CharUnits Offset;
78-
enum InfoKind { VFPtr, VBPtr, Field, Base, VBase, Scissor } Kind;
78+
enum InfoKind { VFPtr, VBPtr, Field, Base, VBase } Kind;
7979
llvm::Type *Data;
8080
union {
8181
const FieldDecl *FD;
@@ -197,7 +197,7 @@ struct CGRecordLowering {
197197
const CXXRecordDecl *Query) const;
198198
void calculateZeroInit();
199199
CharUnits calculateTailClippingOffset(bool isNonVirtualBaseType) const;
200-
void checkBitfieldClipping() const;
200+
void checkBitfieldClipping(bool isNonVirtualBaseType) const;
201201
/// Determines if we need a packed llvm struct.
202202
void determinePacked(bool NVBaseType);
203203
/// Inserts padding everywhere it's needed.
@@ -299,8 +299,8 @@ void CGRecordLowering::lower(bool NVBaseType) {
299299
accumulateVBases();
300300
}
301301
llvm::stable_sort(Members);
302+
checkBitfieldClipping(NVBaseType);
302303
Members.push_back(StorageInfo(Size, getIntNType(8)));
303-
checkBitfieldClipping();
304304
determinePacked(NVBaseType);
305305
insertPadding();
306306
Members.pop_back();
@@ -894,8 +894,6 @@ CGRecordLowering::calculateTailClippingOffset(bool isNonVirtualBaseType) const {
894894
}
895895

896896
void CGRecordLowering::accumulateVBases() {
897-
Members.push_back(MemberInfo(calculateTailClippingOffset(false),
898-
MemberInfo::Scissor, nullptr, RD));
899897
for (const auto &Base : RD->vbases()) {
900898
const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl();
901899
if (BaseDecl->isEmpty())
@@ -950,18 +948,20 @@ void CGRecordLowering::calculateZeroInit() {
950948
}
951949

952950
// Verify accumulateBitfields computed the correct storage representations.
953-
void CGRecordLowering::checkBitfieldClipping() const {
951+
void CGRecordLowering::checkBitfieldClipping(
952+
bool isNonVirtualBaseType LLVM_ATTRIBUTE_UNUSED) const {
954953
#ifndef NDEBUG
954+
auto ScissorOffset = calculateTailClippingOffset(isNonVirtualBaseType);
955955
auto Tail = CharUnits::Zero();
956956
for (const auto &M : Members) {
957-
// Only members with data and the scissor can cut into tail padding.
958-
if (!M.Data && M.Kind != MemberInfo::Scissor)
957+
// Only members with data could possibly overlap.
958+
if (!M.Data)
959959
continue;
960960

961961
assert(M.Offset >= Tail && "Bitfield access unit is not clipped");
962-
Tail = M.Offset;
963-
if (M.Data)
964-
Tail += getSize(M.Data);
962+
Tail = M.Offset + getSize(M.Data);
963+
assert((Tail <= ScissorOffset || M.Offset >= ScissorOffset) &&
964+
"Bitfield straddles scissor offset");
965965
}
966966
#endif
967967
}

0 commit comments

Comments
 (0)