diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-29 18:43:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-29 18:43:28 +0000 |
commit | 02accaeb172fbe179fe20eafa6172606d0c9eae1 (patch) | |
tree | fb4d9e77525fb8ed4156752a8e6d6e01e39f5bf9 /include | |
parent | 9d5d7598db72c00a0fb89dc77198e4f6ebc5294d (diff) | |
download | external_llvm-02accaeb172fbe179fe20eafa6172606d0c9eae1.zip external_llvm-02accaeb172fbe179fe20eafa6172606d0c9eae1.tar.gz external_llvm-02accaeb172fbe179fe20eafa6172606d0c9eae1.tar.bz2 |
Adjust to ilist changes.
Based on the ilist changes avoid allocating an entire Use object for the
end of the Use chain. This saves 8 bytes of memory for each Value allocated
in the program. For 176.gcc, this reduces us from 69.5M -> 66.0M, a 5.3%
memory savings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19925 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Use.h | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/include/llvm/Use.h b/include/llvm/Use.h index 8f29394..3eeea92 100644 --- a/include/llvm/Use.h +++ b/include/llvm/Use.h @@ -32,10 +32,6 @@ class User; // Use is here to make keeping the "use" list of a Value up-to-date really easy. // class Use { - Value *Val; - User *U; - Use *Prev, *Next; - friend struct ilist_traits<Use>; public: inline void init(Value *V, User *U); @@ -65,19 +61,35 @@ public: Value *operator->() { return Val; } const Value *operator->() const { return Val; } + +private: + // NOTE!! The Next/Prev fields MUST stay at the start of this structure. The + // end-token for the ilist is allocated as JUST the next/prev pair to reduce + // memory usage instead of allocating an entire Use. + struct NextPrevPtrs { + Use *Next, *Prev; + } UseLinks; + + Value *Val; + User *U; + friend struct ilist_traits<Use>; }; template<> struct ilist_traits<Use> { - static Use *getPrev(Use *N) { return N->Prev; } - static Use *getNext(Use *N) { return N->Next; } - static const Use *getPrev(const Use *N) { return N->Prev; } - static const Use *getNext(const Use *N) { return N->Next; } - static void setPrev(Use *N, Use *Prev) { N->Prev = Prev; } - static void setNext(Use *N, Use *Next) { N->Next = Next; } - - // createNode - this is used to create the end marker for the use list - static Use *createNode() { return new Use(0,0); } + static Use *getPrev(Use *N) { return N->UseLinks.Prev; } + static Use *getNext(Use *N) { return N->UseLinks.Next; } + static const Use *getPrev(const Use *N) { return N->UseLinks.Prev; } + static const Use *getNext(const Use *N) { return N->UseLinks.Next; } + static void setPrev(Use *N, Use *Prev) { N->UseLinks.Prev = Prev; } + static void setNext(Use *N, Use *Next) { N->UseLinks.Next = Next; } + + /// createSentinal - this is used to create the end marker for the use list. + /// Note that we only allocate a UseLinks structure, which is just enough to + /// hold the next/prev pointers. This saves us 8 bytes of memory for every + /// Value allocated. + static Use *createSentinal() { return (Use*)new Use::NextPrevPtrs(); } + static void destroySentinal(Use *S) { delete (Use::NextPrevPtrs*)S; } void addNodeToList(Use *NTy) {} void removeNodeFromList(Use *NTy) {} |