1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

Reorder Value and User fields to save 8 bytes of padding on 64-bit

Reviewered by: rafael

Differential Revision: http://reviews.llvm.org/D4073

llvm-svn: 210501
This commit is contained in:
Reid Kleckner 2014-06-09 23:32:20 +00:00
parent 8c7b353cd7
commit cb40a8e503
3 changed files with 20 additions and 21 deletions

View File

@ -39,6 +39,10 @@ class User : public Value {
friend struct HungoffOperandTraits; friend struct HungoffOperandTraits;
virtual void anchor(); virtual void anchor();
protected: protected:
/// NumOperands - The number of values used by this User.
///
unsigned NumOperands;
/// OperandList - This is a pointer to the array of Uses for this User. /// OperandList - This is a pointer to the array of Uses for this User.
/// For nodes of fixed arity (e.g. a binary operator) this array will live /// For nodes of fixed arity (e.g. a binary operator) this array will live
/// prefixed to some derived class instance. For nodes of resizable variable /// prefixed to some derived class instance. For nodes of resizable variable
@ -46,13 +50,9 @@ protected:
/// allocated and should be destroyed by the classes' virtual dtor. /// allocated and should be destroyed by the classes' virtual dtor.
Use *OperandList; Use *OperandList;
/// NumOperands - The number of values used by this User.
///
unsigned NumOperands;
void *operator new(size_t s, unsigned Us); void *operator new(size_t s, unsigned Us);
User(Type *ty, unsigned vty, Use *OpList, unsigned NumOps) User(Type *ty, unsigned vty, Use *OpList, unsigned NumOps)
: Value(ty, vty), OperandList(OpList), NumOperands(NumOps) {} : Value(ty, vty), NumOperands(NumOps), OperandList(OpList) {}
Use *allocHungoffUses(unsigned) const; Use *allocHungoffUses(unsigned) const;
void dropHungoffUses() { void dropHungoffUses() {
Use::zap(OperandList, OperandList + NumOperands, true); Use::zap(OperandList, OperandList + NumOperands, true);

View File

@ -67,6 +67,13 @@ typedef StringMapEntry<Value*> ValueName;
/// ///
/// @brief LLVM Value Representation /// @brief LLVM Value Representation
class Value { class Value {
Type *VTy;
Use *UseList;
friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name.
friend class ValueHandleBase;
ValueName *Name;
const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast) const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast)
unsigned char HasValueHandle : 1; // Has a ValueHandle pointing to this? unsigned char HasValueHandle : 1; // Has a ValueHandle pointing to this?
protected: protected:
@ -77,6 +84,11 @@ protected:
unsigned char SubclassOptionalData : 7; unsigned char SubclassOptionalData : 7;
private: private:
/// SubclassData - This member is defined by this class, but is not used for
/// anything. Subclasses can use it to hold whatever state they find useful.
/// This field is initialized to zero by the ctor.
unsigned short SubclassData;
template <typename UseT> // UseT == 'Use' or 'const Use' template <typename UseT> // UseT == 'Use' or 'const Use'
class use_iterator_impl class use_iterator_impl
: public std::iterator<std::forward_iterator_tag, UseT *, ptrdiff_t> { : public std::iterator<std::forward_iterator_tag, UseT *, ptrdiff_t> {
@ -167,18 +179,6 @@ private:
unsigned getOperandNo() const { return UI->getOperandNo(); } unsigned getOperandNo() const { return UI->getOperandNo(); }
}; };
/// SubclassData - This member is defined by this class, but is not used for
/// anything. Subclasses can use it to hold whatever state they find useful.
/// This field is initialized to zero by the ctor.
unsigned short SubclassData;
Type *VTy;
Use *UseList;
friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name.
friend class ValueHandleBase;
ValueName *Name;
void operator=(const Value &) LLVM_DELETED_FUNCTION; void operator=(const Value &) LLVM_DELETED_FUNCTION;
Value(const Value &) LLVM_DELETED_FUNCTION; Value(const Value &) LLVM_DELETED_FUNCTION;

View File

@ -38,13 +38,12 @@ using namespace llvm;
static inline Type *checkType(Type *Ty) { static inline Type *checkType(Type *Ty) {
assert(Ty && "Value defined with a null type: Error!"); assert(Ty && "Value defined with a null type: Error!");
return const_cast<Type*>(Ty); return Ty;
} }
Value::Value(Type *ty, unsigned scid) Value::Value(Type *ty, unsigned scid)
: SubclassID(scid), HasValueHandle(0), : VTy(checkType(ty)), UseList(nullptr), Name(nullptr), SubclassID(scid),
SubclassOptionalData(0), SubclassData(0), VTy((Type*)checkType(ty)), HasValueHandle(0), SubclassOptionalData(0), SubclassData(0) {
UseList(nullptr), Name(nullptr) {
// FIXME: Why isn't this in the subclass gunk?? // FIXME: Why isn't this in the subclass gunk??
// Note, we cannot call isa<CallInst> before the CallInst has been // Note, we cannot call isa<CallInst> before the CallInst has been
// constructed. // constructed.