diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-10-15 20:39:05 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-10-15 20:39:05 +0000 |
| commit | 8d5aeb269869b66919864f93e706d054d142b29d (patch) | |
| tree | a47c61cda8648d154571bf867fbe9f3056fa8e3e /llvm | |
| parent | fcece4d2162e47c0f7325d1c262f460ff078aab7 (diff) | |
| download | bcm5719-llvm-8d5aeb269869b66919864f93e706d054d142b29d.tar.gz bcm5719-llvm-8d5aeb269869b66919864f93e706d054d142b29d.zip | |
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).
llvm-svn: 219845
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/IR/Metadata.h | 3 | ||||
| -rw-r--r-- | llvm/include/llvm/IR/User.h | 7 | ||||
| -rw-r--r-- | llvm/include/llvm/IR/Value.h | 13 | ||||
| -rw-r--r-- | llvm/lib/IR/Value.cpp | 3 |
4 files changed, 18 insertions, 8 deletions
diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h index 8b33d7022c7..be0f54974fd 100644 --- a/llvm/include/llvm/IR/Metadata.h +++ b/llvm/include/llvm/IR/Metadata.h @@ -126,9 +126,6 @@ class MDNode : public Value, public FoldingSetNode { /// \brief If the MDNode is uniqued cache the hash to speed up lookup. unsigned Hash; - /// \brief Number of co-allocated 'MDNodeOperand' items. - unsigned NumOperands; - /// \brief Subclass data enums. enum { /// FunctionLocalBit - This bit is set if this MDNode is function local. diff --git a/llvm/include/llvm/IR/User.h b/llvm/include/llvm/IR/User.h index fb5abe0c0e4..f578227d6ca 100644 --- a/llvm/include/llvm/IR/User.h +++ b/llvm/include/llvm/IR/User.h @@ -39,9 +39,6 @@ class User : public Value { friend struct HungoffOperandTraits; virtual void anchor(); 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. /// /// 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); 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; void dropHungoffUses() { Use::zap(OperandList, OperandList + NumOperands, true); diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h index 02630d8c666..efe0cca7bb4 100644 --- a/llvm/include/llvm/IR/Value.h +++ b/llvm/include/llvm/IR/Value.h @@ -92,6 +92,19 @@ private: /// field is initialized to zero by the ctor. 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' class use_iterator_impl : public std::iterator<std::forward_iterator_tag, UseT *, ptrdiff_t> { diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index b5af72b858e..862f08c8966 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -45,7 +45,8 @@ static inline Type *checkType(Type *Ty) { Value::Value(Type *ty, unsigned 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?? // Note, we cannot call isa<CallInst> before the CallInst has been // constructed. |

