llvm.org GIT mirror llvm / ffe9e63
Use references in DF iterators. This eliminates copy-ctor calls on huge objects (graphs) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45063 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 12 years ago
2 changed file(s) with 28 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
9595 typedef df_iterator _Self;
9696
9797 // Provide static begin and end methods as our public "constructors"
98 static inline _Self begin(GraphT G) {
98 static inline _Self begin(const GraphT& G) {
9999 return _Self(GT::getEntryNode(G));
100100 }
101 static inline _Self end(GraphT G) { return _Self(); }
101 static inline _Self end(const GraphT& G) { return _Self(); }
102102
103103 // Static begin and end methods as our public ctors for external iterators
104 static inline _Self begin(GraphT G, SetType &S) {
104 static inline _Self begin(const GraphT& G, SetType &S) {
105105 return _Self(GT::getEntryNode(G), S);
106106 }
107 static inline _Self end(GraphT G, SetType &S) { return _Self(S); }
107 static inline _Self end(const GraphT& G, SetType &S) { return _Self(S); }
108108
109109 inline bool operator==(const _Self& x) const {
110110 return VisitStack.size() == x.VisitStack.size() &&
161161 // Provide global constructors that automatically figure out correct types...
162162 //
163163 template
164 df_iterator df_begin(T G) {
164 df_iterator df_begin(const T& G) {
165165 return df_iterator::begin(G);
166166 }
167167
168168 template
169 df_iterator df_end(T G) {
169 df_iterator df_end(const T& G) {
170170 return df_iterator::end(G);
171171 }
172172
178178 };
179179
180180 template
181 df_ext_iterator df_ext_begin(T G, SetTy &S) {
181 df_ext_iterator df_ext_begin(const T& G, SetTy &S) {
182182 return df_ext_iterator::begin(G, S);
183183 }
184184
185185 template
186 df_ext_iterator df_ext_end(T G, SetTy &S) {
186 df_ext_iterator df_ext_end(const T& G, SetTy &S) {
187187 return df_ext_iterator::end(G, S);
188188 }
189189
198198 };
199199
200200 template
201 idf_iterator idf_begin(T G) {
202 return idf_iterator::begin(G);
203 }
204
205 template
206 idf_iterator idf_end(T G){
207 return idf_iterator::end(G);
201 idf_iterator idf_begin(const T& G) {
202 Inverse DummyG;
203 return idf_iterator::begin(DummyG);
204 }
205
206 template
207 idf_iterator idf_end(const T& G){
208 Inverse DummyG;
209 return idf_iterator::end(DummyG);
208210 }
209211
210212 // Provide global definitions of external inverse depth first iterators...
217219 };
218220
219221 template
220 idf_ext_iterator idf_ext_begin(T G, SetTy &S) {
221 return idf_ext_iterator::begin(G, S);
222 }
223
224 template
225 idf_ext_iterator idf_ext_end(T G, SetTy &S) {
226 return idf_ext_iterator::end(G, S);
222 idf_ext_iterator idf_ext_begin(const T& G, SetTy &S) {
223 Inverse DummyG(G);
224 return idf_ext_iterator::begin(DummyG, S);
225 }
226
227 template
228 idf_ext_iterator idf_ext_end(const T& G, SetTy &S) {
229 Inverse DummyG(G);
230 return idf_ext_iterator::end(DummyG, S);
227231 }
228232
229233 } // End llvm namespace
7272 //
7373 template
7474 struct Inverse {
75 GraphType &Graph;
75 const GraphType &Graph;
7676
77 inline Inverse(GraphType &G) : Graph(G) {}
77 inline Inverse(const GraphType &G) : Graph(G) {}
7878 };
7979
8080 // Provide a partial specialization of GraphTraits so that the inverse of an inverse