@@ -106,14 +106,13 @@ class po_iterator : public po_iterator_storage<SetType, ExtStorage> {
106
106
using NodeRef = typename GT::NodeRef;
107
107
using ChildItTy = typename GT::ChildIteratorType;
108
108
109
- // / Used to maintain the ordering.
110
- // / First element is basic block pointer, second is iterator for the next
111
- // / child to visit, third is the end iterator.
112
- SmallVector<std::tuple<NodeRef, ChildItTy, ChildItTy>, 8 > VisitStack;
109
+ // VisitStack - Used to maintain the ordering. Top = current block
110
+ // First element is basic block pointer, second is the 'next child' to visit
111
+ SmallVector<std::pair<NodeRef, ChildItTy>, 8 > VisitStack;
113
112
114
113
po_iterator (NodeRef BB) {
115
114
this ->insertEdge (std::optional<NodeRef>(), BB);
116
- VisitStack.emplace_back (BB, GT::child_begin (BB) , GT::child_end (BB));
115
+ VisitStack.push_back ( std::make_pair (BB, GT::child_begin (BB) ));
117
116
traverseChild ();
118
117
}
119
118
@@ -122,7 +121,7 @@ class po_iterator : public po_iterator_storage<SetType, ExtStorage> {
122
121
po_iterator (NodeRef BB, SetType &S)
123
122
: po_iterator_storage<SetType, ExtStorage>(S) {
124
123
if (this ->insertEdge (std::optional<NodeRef>(), BB)) {
125
- VisitStack.emplace_back (BB, GT::child_begin (BB) , GT::child_end (BB));
124
+ VisitStack.push_back ( std::make_pair (BB, GT::child_begin (BB) ));
126
125
traverseChild ();
127
126
}
128
127
}
@@ -132,14 +131,12 @@ class po_iterator : public po_iterator_storage<SetType, ExtStorage> {
132
131
} // End is when stack is empty.
133
132
134
133
void traverseChild () {
135
- while (true ) {
136
- auto &[ParentBB, It, End] = VisitStack.back ();
137
- if (It == End)
138
- break ;
139
- NodeRef BB = *It++;
140
- if (this ->insertEdge (std::optional<NodeRef>(ParentBB), BB)) {
134
+ while (VisitStack.back ().second != GT::child_end (VisitStack.back ().first )) {
135
+ NodeRef BB = *VisitStack.back ().second ++;
136
+ if (this ->insertEdge (std::optional<NodeRef>(VisitStack.back ().first ),
137
+ BB)) {
141
138
// If the block is not visited...
142
- VisitStack.emplace_back (BB, GT::child_begin (BB) , GT::child_end (BB));
139
+ VisitStack.push_back ( std::make_pair (BB, GT::child_begin (BB) ));
143
140
}
144
141
}
145
142
}
@@ -161,7 +158,7 @@ class po_iterator : public po_iterator_storage<SetType, ExtStorage> {
161
158
}
162
159
bool operator !=(const po_iterator &x) const { return !(*this == x); }
163
160
164
- const NodeRef &operator *() const { return std::get< 0 >( VisitStack.back ()) ; }
161
+ const NodeRef &operator *() const { return VisitStack.back (). first ; }
165
162
166
163
// This is a nonstandard operator-> that dereferences the pointer an extra
167
164
// time... so that you can actually call methods ON the BasicBlock, because
@@ -170,7 +167,7 @@ class po_iterator : public po_iterator_storage<SetType, ExtStorage> {
170
167
NodeRef operator ->() const { return **this ; }
171
168
172
169
po_iterator &operator ++() { // Preincrement
173
- this ->finishPostorder (std::get< 0 >( VisitStack.back ()) );
170
+ this ->finishPostorder (VisitStack.back (). first );
174
171
VisitStack.pop_back ();
175
172
if (!VisitStack.empty ())
176
173
traverseChild ();
0 commit comments