llvm.org GIT mirror llvm / 84a9919
[LCG] Re-order the lazy node iterator below the node type to make some subsequent work I'm doing not have its delta obscured by boring code motion. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257161 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 4 years ago
1 changed file(s) with 49 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
103103 public:
104104 class Node;
105105 class SCC;
106 class iterator;
106107 typedef SmallVector, 4> NodeVectorT;
107108 typedef SmallVectorImpl> NodeVectorImplT;
109
110 /// A node in the call graph.
111 ///
112 /// This represents a single node. It's primary roles are to cache the list of
113 /// callees, de-duplicate and provide fast testing of whether a function is
114 /// a callee, and facilitate iteration of child nodes in the graph.
115 class Node {
116 friend class LazyCallGraph;
117 friend class LazyCallGraph::SCC;
118
119 LazyCallGraph *G;
120 Function &F;
121
122 // We provide for the DFS numbering and Tarjan walk lowlink numbers to be
123 // stored directly within the node.
124 int DFSNumber;
125 int LowLink;
126
127 mutable NodeVectorT Callees;
128 DenseMap CalleeIndexMap;
129
130 /// Basic constructor implements the scanning of F into Callees and
131 /// CalleeIndexMap.
132 Node(LazyCallGraph &G, Function &F);
133
134 /// Internal helper to insert a callee.
135 void insertEdgeInternal(Function &Callee);
136
137 /// Internal helper to insert a callee.
138 void insertEdgeInternal(Node &CalleeN);
139
140 /// Internal helper to remove a callee from this node.
141 void removeEdgeInternal(Function &Callee);
142
143 public:
144 typedef LazyCallGraph::iterator iterator;
145
146 Function &getFunction() const { return F; }
147
148 iterator begin() const {
149 return iterator(*G, Callees.begin(), Callees.end());
150 }
151 iterator end() const { return iterator(*G, Callees.end(), Callees.end()); }
152
153 /// Equality is defined as address equality.
154 bool operator==(const Node &N) const { return this == &N; }
155 bool operator!=(const Node &N) const { return !operator==(N); }
156 };
108157
109158 /// A lazy iterator used for both the entry nodes and child nodes.
110159 ///
149198 *I = &ChildN;
150199 return ChildN;
151200 }
152 };
153
154 /// A node in the call graph.
155 ///
156 /// This represents a single node. It's primary roles are to cache the list of
157 /// callees, de-duplicate and provide fast testing of whether a function is
158 /// a callee, and facilitate iteration of child nodes in the graph.
159 class Node {
160 friend class LazyCallGraph;
161 friend class LazyCallGraph::SCC;
162
163 LazyCallGraph *G;
164 Function &F;
165
166 // We provide for the DFS numbering and Tarjan walk lowlink numbers to be
167 // stored directly within the node.
168 int DFSNumber;
169 int LowLink;
170
171 mutable NodeVectorT Callees;
172 DenseMap CalleeIndexMap;
173
174 /// Basic constructor implements the scanning of F into Callees and
175 /// CalleeIndexMap.
176 Node(LazyCallGraph &G, Function &F);
177
178 /// Internal helper to insert a callee.
179 void insertEdgeInternal(Function &Callee);
180
181 /// Internal helper to insert a callee.
182 void insertEdgeInternal(Node &CalleeN);
183
184 /// Internal helper to remove a callee from this node.
185 void removeEdgeInternal(Function &Callee);
186
187 public:
188 typedef LazyCallGraph::iterator iterator;
189
190 Function &getFunction() const { return F; }
191
192 iterator begin() const {
193 return iterator(*G, Callees.begin(), Callees.end());
194 }
195 iterator end() const { return iterator(*G, Callees.end(), Callees.end()); }
196
197 /// Equality is defined as address equality.
198 bool operator==(const Node &N) const { return this == &N; }
199 bool operator!=(const Node &N) const { return !operator==(N); }
200201 };
201202
202203 /// An SCC of the call graph.