Skip to content

Commit 16bf89e

Browse files
committedJun 9, 2014
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
1 parent cd68ae3 commit 16bf89e

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed
 

‎llvm/include/llvm/IR/User.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ class User : public Value {
3939
friend struct HungoffOperandTraits;
4040
virtual void anchor();
4141
protected:
42+
/// NumOperands - The number of values used by this User.
43+
///
44+
unsigned NumOperands;
45+
4246
/// OperandList - This is a pointer to the array of Uses for this User.
4347
/// For nodes of fixed arity (e.g. a binary operator) this array will live
4448
/// prefixed to some derived class instance. For nodes of resizable variable
4549
/// arity (e.g. PHINodes, SwitchInst etc.), this memory will be dynamically
4650
/// allocated and should be destroyed by the classes' virtual dtor.
4751
Use *OperandList;
4852

49-
/// NumOperands - The number of values used by this User.
50-
///
51-
unsigned NumOperands;
52-
5353
void *operator new(size_t s, unsigned Us);
5454
User(Type *ty, unsigned vty, Use *OpList, unsigned NumOps)
55-
: Value(ty, vty), OperandList(OpList), NumOperands(NumOps) {}
55+
: Value(ty, vty), NumOperands(NumOps), OperandList(OpList) {}
5656
Use *allocHungoffUses(unsigned) const;
5757
void dropHungoffUses() {
5858
Use::zap(OperandList, OperandList + NumOperands, true);

‎llvm/include/llvm/IR/Value.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ typedef StringMapEntry<Value*> ValueName;
6767
///
6868
/// @brief LLVM Value Representation
6969
class Value {
70+
Type *VTy;
71+
Use *UseList;
72+
73+
friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name.
74+
friend class ValueHandleBase;
75+
ValueName *Name;
76+
7077
const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast)
7178
unsigned char HasValueHandle : 1; // Has a ValueHandle pointing to this?
7279
protected:
@@ -77,6 +84,11 @@ class Value {
7784
unsigned char SubclassOptionalData : 7;
7885

7986
private:
87+
/// SubclassData - This member is defined by this class, but is not used for
88+
/// anything. Subclasses can use it to hold whatever state they find useful.
89+
/// This field is initialized to zero by the ctor.
90+
unsigned short SubclassData;
91+
8092
template <typename UseT> // UseT == 'Use' or 'const Use'
8193
class use_iterator_impl
8294
: public std::iterator<std::forward_iterator_tag, UseT *, ptrdiff_t> {
@@ -167,18 +179,6 @@ class Value {
167179
unsigned getOperandNo() const { return UI->getOperandNo(); }
168180
};
169181

170-
/// SubclassData - This member is defined by this class, but is not used for
171-
/// anything. Subclasses can use it to hold whatever state they find useful.
172-
/// This field is initialized to zero by the ctor.
173-
unsigned short SubclassData;
174-
175-
Type *VTy;
176-
Use *UseList;
177-
178-
friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name.
179-
friend class ValueHandleBase;
180-
ValueName *Name;
181-
182182
void operator=(const Value &) LLVM_DELETED_FUNCTION;
183183
Value(const Value &) LLVM_DELETED_FUNCTION;
184184

‎llvm/lib/IR/Value.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ using namespace llvm;
3838

3939
static inline Type *checkType(Type *Ty) {
4040
assert(Ty && "Value defined with a null type: Error!");
41-
return const_cast<Type*>(Ty);
41+
return Ty;
4242
}
4343

4444
Value::Value(Type *ty, unsigned scid)
45-
: SubclassID(scid), HasValueHandle(0),
46-
SubclassOptionalData(0), SubclassData(0), VTy((Type*)checkType(ty)),
47-
UseList(nullptr), Name(nullptr) {
45+
: VTy(checkType(ty)), UseList(nullptr), Name(nullptr), SubclassID(scid),
46+
HasValueHandle(0), SubclassOptionalData(0), SubclassData(0) {
4847
// FIXME: Why isn't this in the subclass gunk??
4948
// Note, we cannot call isa<CallInst> before the CallInst has been
5049
// constructed.

0 commit comments

Comments
 (0)
Please sign in to comment.