IRgen: Eliminate now unused fields from CGBitFieldInfo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101344 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 1f56bb7..a4fb431 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -124,10 +124,9 @@
// layout object. However, this is blocked on other cleanups to the
// Objective-C code, so for now we just live with allocating a bunch of these
// objects.
- unsigned FieldNo = 0; // This value is unused.
CGBitFieldInfo *Info =
- new (CGF.CGM.getContext()) CGBitFieldInfo(
- LTy, FieldNo, BitOffset, BitFieldSize, IvarTy->isSignedIntegerType());
+ new (CGF.CGM.getContext()) CGBitFieldInfo(BitFieldSize,
+ IvarTy->isSignedIntegerType());
// We always construct a single, possibly unaligned, access for this case.
Info->setNumComponents(1);
diff --git a/lib/CodeGen/CGRecordLayout.h b/lib/CodeGen/CGRecordLayout.h
index 86ae27e..dd60dbd 100644
--- a/lib/CodeGen/CGRecordLayout.h
+++ b/lib/CodeGen/CGRecordLayout.h
@@ -77,9 +77,6 @@
};
private:
- /// The number of access components to use.
- unsigned NumComponents;
-
/// The components to use to access the bit-field. We may need up to three
/// separate components to support up to i64 bit-field access (4 + 2 + 1 byte
/// accesses).
@@ -87,20 +84,20 @@
// FIXME: De-hardcode this, just allocate following the struct.
AccessInfo Components[3];
-public:
- CGBitFieldInfo(const llvm::Type *FieldTy, unsigned FieldNo,
- unsigned Start, unsigned Size, bool IsSigned)
- : FieldTy(FieldTy), FieldNo(FieldNo),
- Start(Start), Size(Size), IsSigned(IsSigned) {}
-
- const llvm::Type *FieldTy;
- unsigned FieldNo;
-
- unsigned Start;
+ /// The total size of the bit-field, in bits.
unsigned Size;
+
+ /// The number of access components to use.
+ unsigned NumComponents;
+
+ /// Whether the bit-field is signed.
bool IsSigned : 1;
public:
+ CGBitFieldInfo(unsigned Size, bool IsSigned)
+ : Size(Size), IsSigned(IsSigned) {}
+
+public:
/// \brief Check whether this bit-field access is (i.e., should be sign
/// extended on loads).
bool isSigned() const { return IsSigned; }
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp
index 45acb03..cfdae24 100644
--- a/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -153,15 +153,15 @@
uint64_t TypeSizeInBytes = Types.getTargetData().getTypeAllocSize(Ty);
uint64_t TypeSizeInBits = TypeSizeInBytes * 8;
+ unsigned StartBit = FieldOffset % TypeSizeInBits;
bool IsSigned = FD->getType()->isSignedIntegerType();
- CGBitFieldInfo BFI(Ty, FieldOffset / TypeSizeInBits,
- FieldOffset % TypeSizeInBits, FieldSize, IsSigned);
+ CGBitFieldInfo BFI(FieldSize, IsSigned);
// The current policy is to always access the bit-field using the source type
// of the bit-field. With the C bit-field rules, this implies that we always
// use either one or two accesses, and two accesses can only occur with a
// packed structure when the bit-field straddles an alignment boundary.
- unsigned LowBits = std::min(FieldSize, TypeSizeInBits - BFI.Start);
+ unsigned LowBits = std::min(FieldSize, TypeSizeInBits - StartBit);
bool NeedsHighAccess = LowBits != FieldSize;
BFI.setNumComponents(1 + NeedsHighAccess);
@@ -170,7 +170,7 @@
LowAccess.FieldIndex = 0;
LowAccess.FieldByteOffset =
TypeSizeInBytes * ((FieldOffset / 8) / TypeSizeInBytes);
- LowAccess.FieldBitStart = BFI.Start;
+ LowAccess.FieldBitStart = StartBit;
LowAccess.AccessWidth = TypeSizeInBits;
// FIXME: This might be wrong!
LowAccess.AccessAlignment = 0;
@@ -565,9 +565,6 @@
void CGBitFieldInfo::print(llvm::raw_ostream &OS) const {
OS << "<CGBitFieldInfo";
- OS << " FieldTy:" << *FieldTy;
- OS << " FieldNo:" << FieldNo;
- OS << " Start:" << Start;
OS << " Size:" << Size;
OS << " IsSigned:" << IsSigned << "\n";