@@ -163,9 +163,7 @@ typename RegionBase<Tr>::BlockT *RegionBase<Tr>::getEnteringBlock() const {
163
163
assert (!AllowRepeats && " Unexpected parameter value." );
164
164
return DT->getNode (Pred) && !contains (Pred) ? Pred : nullptr ;
165
165
};
166
- BlockT *entry = getEntry ();
167
- return find_singleton<BlockT>(make_range (InvBlockTraits::child_begin (entry),
168
- InvBlockTraits::child_end (entry)),
166
+ return find_singleton<BlockT>(llvm::inverse_children<BlockT *>(getEntry ()),
169
167
isEnteringBlock);
170
168
}
171
169
@@ -177,10 +175,7 @@ bool RegionBase<Tr>::getExitingBlocks(
177
175
if (!exit)
178
176
return CoverAll;
179
177
180
- for (PredIterTy PI = InvBlockTraits::child_begin (exit),
181
- PE = InvBlockTraits::child_end (exit);
182
- PI != PE; ++PI) {
183
- BlockT *Pred = *PI;
178
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(exit)) {
184
179
if (contains (Pred)) {
185
180
Exitings.push_back (Pred);
186
181
continue ;
@@ -202,8 +197,7 @@ typename RegionBase<Tr>::BlockT *RegionBase<Tr>::getExitingBlock() const {
202
197
assert (!AllowRepeats && " Unexpected parameter value." );
203
198
return contains (Pred) ? Pred : nullptr ;
204
199
};
205
- return find_singleton<BlockT>(make_range (InvBlockTraits::child_begin (exit),
206
- InvBlockTraits::child_end (exit)),
200
+ return find_singleton<BlockT>(llvm::inverse_children<BlockT *>(exit),
207
201
isContained);
208
202
}
209
203
@@ -244,16 +238,14 @@ void RegionBase<Tr>::verifyBBInRegion(BlockT *BB) const {
244
238
245
239
BlockT *entry = getEntry (), *exit = getExit ();
246
240
247
- for (BlockT *Succ :
248
- make_range (BlockTraits::child_begin (BB), BlockTraits::child_end (BB))) {
241
+ for (BlockT *Succ : llvm::children<BlockT *>(BB)) {
249
242
if (!contains (Succ) && exit != Succ)
250
243
report_fatal_error (" Broken region found: edges leaving the region must go "
251
244
" to the exit node!" );
252
245
}
253
246
254
247
if (entry != BB) {
255
- for (BlockT *Pred : make_range (InvBlockTraits::child_begin (BB),
256
- InvBlockTraits::child_end (BB))) {
248
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(BB)) {
257
249
// Allow predecessors that are unreachable, as these are ignored during
258
250
// region analysis.
259
251
if (!contains (Pred) && DT->isReachableFromEntry (Pred))
@@ -271,8 +263,7 @@ void RegionBase<Tr>::verifyWalk(BlockT *BB, std::set<BlockT *> *visited) const {
271
263
272
264
verifyBBInRegion (BB);
273
265
274
- for (BlockT *Succ :
275
- make_range (BlockTraits::child_begin (BB), BlockTraits::child_end (BB))) {
266
+ for (BlockT *Succ : llvm::children<BlockT *>(BB)) {
276
267
if (Succ != exit && visited->find (Succ) == visited->end ())
277
268
verifyWalk (Succ, visited);
278
269
}
@@ -453,8 +444,7 @@ typename Tr::RegionT *RegionBase<Tr>::getExpandedRegion() const {
453
444
RegionT *R = RI->getRegionFor (exit);
454
445
455
446
if (R->getEntry () != exit) {
456
- for (BlockT *Pred : make_range (InvBlockTraits::child_begin (getExit ()),
457
- InvBlockTraits::child_end (getExit ())))
447
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(getExit ()))
458
448
if (!contains (Pred))
459
449
return nullptr ;
460
450
if (Tr::getNumSuccessors (exit) == 1 )
@@ -465,8 +455,7 @@ typename Tr::RegionT *RegionBase<Tr>::getExpandedRegion() const {
465
455
while (R->getParent () && R->getParent ()->getEntry () == exit)
466
456
R = R->getParent ();
467
457
468
- for (BlockT *Pred : make_range (InvBlockTraits::child_begin (getExit ()),
469
- InvBlockTraits::child_end (getExit ()))) {
458
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(getExit ())) {
470
459
if (!(contains (Pred) || R->contains (Pred)))
471
460
return nullptr ;
472
461
}
@@ -553,8 +542,7 @@ void RegionInfoBase<Tr>::verifyBBMap(const RegionT *R) const {
553
542
template <class Tr >
554
543
bool RegionInfoBase<Tr>::isCommonDomFrontier(BlockT *BB, BlockT *entry,
555
544
BlockT *exit) const {
556
- for (BlockT *P : make_range (InvBlockTraits::child_begin (BB),
557
- InvBlockTraits::child_end (BB))) {
545
+ for (BlockT *P : llvm::inverse_children<BlockT *>(BB)) {
558
546
if (DT->dominates (entry, P) && !DT->dominates (exit, P))
559
547
return false ;
560
548
}
@@ -837,8 +825,7 @@ RegionInfoBase<Tr>::getMaxRegionExit(BlockT *BB) const {
837
825
ExitR->getParent ()->getEntry () == Exit)
838
826
ExitR = ExitR->getParent ();
839
827
840
- for (BlockT *Pred : make_range (InvBlockTraits::child_begin (Exit),
841
- InvBlockTraits::child_end (Exit))) {
828
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(Exit)) {
842
829
if (!R->contains (Pred) && !ExitR->contains (Pred))
843
830
break ;
844
831
}
0 commit comments