mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-27 00:15:58 +00:00
IR: Move NumOperands from User to Value, NFC
Store `User::NumOperands` (and `MDNode::NumOperands`) in `Value`. On 64-bit host architectures, this reduces `sizeof(User)` and all subclasses by 8, and has no effect on `sizeof(Value)` (or, incidentally, on `sizeof(MDNode)`). On 32-bit host architectures, this increases `sizeof(Value)` by 4. However, it has no effect on `sizeof(User)` and `sizeof(MDNode)`, so the only concrete subclasses of `Value` that actually see the increase are `BasicBlock`, `Argument`, `InlineAsm`, and `MDString`. Moreover, I'll be shocked and confused if this causes a tangible memory regression. This has no functionality change (other than memory footprint). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219845 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
40dd9d68d7
commit
9ca230f11c
@ -126,9 +126,6 @@ class MDNode : public Value, public FoldingSetNode {
|
|||||||
/// \brief If the MDNode is uniqued cache the hash to speed up lookup.
|
/// \brief If the MDNode is uniqued cache the hash to speed up lookup.
|
||||||
unsigned Hash;
|
unsigned Hash;
|
||||||
|
|
||||||
/// \brief Number of co-allocated 'MDNodeOperand' items.
|
|
||||||
unsigned NumOperands;
|
|
||||||
|
|
||||||
/// \brief Subclass data enums.
|
/// \brief Subclass data enums.
|
||||||
enum {
|
enum {
|
||||||
/// FunctionLocalBit - This bit is set if this MDNode is function local.
|
/// FunctionLocalBit - This bit is set if this MDNode is function local.
|
||||||
|
@ -39,9 +39,6 @@ class User : public Value {
|
|||||||
friend struct HungoffOperandTraits;
|
friend struct HungoffOperandTraits;
|
||||||
virtual void anchor();
|
virtual void anchor();
|
||||||
protected:
|
protected:
|
||||||
/// \brief The number of values used by this User.
|
|
||||||
unsigned NumOperands;
|
|
||||||
|
|
||||||
/// \brief This is a pointer to the array of Uses for this User.
|
/// \brief 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
|
||||||
@ -52,7 +49,9 @@ protected:
|
|||||||
|
|
||||||
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), NumOperands(NumOps), OperandList(OpList) {}
|
: Value(ty, vty), OperandList(OpList) {
|
||||||
|
NumOperands = NumOps;
|
||||||
|
}
|
||||||
Use *allocHungoffUses(unsigned) const;
|
Use *allocHungoffUses(unsigned) const;
|
||||||
void dropHungoffUses() {
|
void dropHungoffUses() {
|
||||||
Use::zap(OperandList, OperandList + NumOperands, true);
|
Use::zap(OperandList, OperandList + NumOperands, true);
|
||||||
|
@ -92,6 +92,19 @@ private:
|
|||||||
/// field is initialized to zero by the ctor.
|
/// field is initialized to zero by the ctor.
|
||||||
unsigned short SubclassData;
|
unsigned short SubclassData;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// \brief The number of operands in the subclass.
|
||||||
|
///
|
||||||
|
/// This member is defined by this class, but not used for anything.
|
||||||
|
/// Subclasses can use it to store their number of operands, if they have
|
||||||
|
/// any.
|
||||||
|
///
|
||||||
|
/// This is stored here to save space in User on 64-bit hosts. Since most
|
||||||
|
/// instances of Value have operands, 32-bit hosts aren't significantly
|
||||||
|
/// affected.
|
||||||
|
unsigned NumOperands;
|
||||||
|
|
||||||
|
private:
|
||||||
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> {
|
||||||
|
@ -45,7 +45,8 @@ static inline Type *checkType(Type *Ty) {
|
|||||||
|
|
||||||
Value::Value(Type *ty, unsigned scid)
|
Value::Value(Type *ty, unsigned scid)
|
||||||
: VTy(checkType(ty)), UseList(nullptr), Name(nullptr), SubclassID(scid),
|
: VTy(checkType(ty)), UseList(nullptr), Name(nullptr), SubclassID(scid),
|
||||||
HasValueHandle(0), SubclassOptionalData(0), SubclassData(0) {
|
HasValueHandle(0), SubclassOptionalData(0), SubclassData(0),
|
||||||
|
NumOperands(0) {
|
||||||
// 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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user