llvm.org GIT mirror llvm / fd7a918
Resubmit an earlier patch of mine: reduce the size of relevant "ghostly" sentinels by a pointer. This attempt now makes the compactification dependent on the configure variable LLVM_COMPACT_SENTINELS and should not cause any bootstrap failures for llvm-gcc any more. Please note that this is not yet the final version, and (as settled with Chris) I shall take out the autofoo/cmake portions in the next days. This will also lose the assertability on sentinel dereferencing and operator++, but that seems an acceptable price to pay for the simplified build logic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79938 91177308-0d34-0410-b5e6-96231b3b80d8 Gabor Greif 10 years ago
7 changed file(s) with 48 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
3838 #define LLVM_ADT_ILIST_H
3939
4040 #include "llvm/ADT/iterator.h"
41 #include "llvm/Config/config.h"
4142 #include
43
44 #if defined(LLVM_COMPACT_SENTINELS) && LLVM_COMPACT_SENTINELS
45 # define sentinel_tail_assert(COND)
46 #else
47 # define sentinel_tail_assert(COND) assert(COND)
48 #endif
4249
4350 namespace llvm {
4451
188195
189196 // Accessors...
190197 operator pointer() const {
191 assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
198 sentinel_tail_assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
192199 return NodePtr;
193200 }
194201
195202 reference operator*() const {
196 assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
203 sentinel_tail_assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
197204 return *NodePtr;
198205 }
199206 pointer operator->() const { return &operator*(); }
214221 }
215222 ilist_iterator &operator++() { // preincrement - Advance
216223 NodePtr = Traits::getNext(NodePtr);
217 assert(NodePtr && "++'d off the end of an ilist!");
224 sentinel_tail_assert(NodePtr && "++'d off the end of an ilist!");
218225 return *this;
219226 }
220227 ilist_iterator operator--(int) { // postdecrement operators...
1414 #ifndef LLVM_ADT_ILIST_NODE_H
1515 #define LLVM_ADT_ILIST_NODE_H
1616
17 #include "llvm/Config/config.h"
18
1719 namespace llvm {
1820
1921 template
20 struct ilist_nextprev_traits;
22 struct ilist_traits;
23
24 /// ilist_half_node - Base class that provides prev services for sentinels.
25 ///
26 template
27 class ilist_half_node {
28 friend struct ilist_traits;
29 NodeTy *Prev;
30 protected:
31 NodeTy *getPrev() { return Prev; }
32 const NodeTy *getPrev() const { return Prev; }
33 void setPrev(NodeTy *P) { Prev = P; }
34 ilist_half_node() : Prev(0) {}
35 };
2136
2237 template
23 struct ilist_traits;
38 struct ilist_nextprev_traits;
2439
2540 /// ilist_node - Base class that provides next/prev services for nodes
2641 /// that use ilist_nextprev_traits or ilist_default_traits.
2742 ///
2843 template
29 class ilist_node {
30 private:
44 class ilist_node : ilist_half_node {
3145 friend struct ilist_nextprev_traits;
3246 friend struct ilist_traits;
33 NodeTy *Prev, *Next;
34 NodeTy *getPrev() { return Prev; }
47 NodeTy *Next;
3548 NodeTy *getNext() { return Next; }
36 const NodeTy *getPrev() const { return Prev; }
3749 const NodeTy *getNext() const { return Next; }
38 void setPrev(NodeTy *N) { Prev = N; }
3950 void setNext(NodeTy *N) { Next = N; }
4051 protected:
41 ilist_node() : Prev(0), Next(0) {}
52 ilist_node() : Next(0) {}
4253 };
54
55 /// When assertions are off, the Next field of sentinels
56 /// will not be accessed. So it is not necessary to allocate
57 /// space for it. The following macro selects the most
58 /// efficient traits class. The LLVM_COMPACT_SENTINELS
59 /// configuration variable controls this.
60 ///
61 #if defined(LLVM_COMPACT_SENTINELS) && LLVM_COMPACT_SENTINELS
62 # define ILIST_NODE ilist_half_node
63 #else
64 # define ILIST_NODE ilist_node
65 #endif
4366
4467 } // End llvm namespace
4568
4646 Instruction *ensureHead(Instruction*) const { return createSentinel(); }
4747 static void noteHead(Instruction*, Instruction*) {}
4848 private:
49 mutable ilist_node Sentinel;
49 mutable ILIST_NODE Sentinel;
5050 };
5151
5252 /// This represents a single basic block in LLVM. A basic block is simply a
2525 template <>
2626 struct ilist_traits : public ilist_default_traits {
2727 private:
28 mutable ilist_node Sentinel;
28 mutable ILIST_NODE Sentinel;
2929
3030 // this is only set by the MachineBasicBlock owning the LiveList
3131 friend class MachineBasicBlock;
3737 template <>
3838 struct ilist_traits
3939 : public ilist_default_traits {
40 mutable ilist_node Sentinel;
40 mutable ILIST_NODE Sentinel;
4141 public:
4242 MachineBasicBlock *createSentinel() const {
4343 return static_cast(&Sentinel);
3636
3737 template<> struct ilist_traits : public ilist_default_traits {
3838 private:
39 mutable ilist_node Sentinel;
39 mutable ILIST_NODE Sentinel;
4040 public:
4141 SDNode *createSentinel() const {
4242 return static_cast(&Sentinel);
4444
4545 static ValueSymbolTable *getSymTab(Function *ItemParent);
4646 private:
47 mutable ilist_node Sentinel;
47 mutable ILIST_NODE Sentinel;
4848 };
4949
5050 template<> struct ilist_traits
6161
6262 static ValueSymbolTable *getSymTab(Function *ItemParent);
6363 private:
64 mutable ilist_node Sentinel;
64 mutable ILIST_NODE Sentinel;
6565 };
6666
6767 class Function : public GlobalValue,