[llvm] fbd00a4 - [Analysis] Use llvm::children and llvm::inverse_children (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 18:54:20 PST 2024
Author: Kazu Hirata
Date: 2024-01-19T18:54:07-08:00
New Revision: fbd00a47754c1279145b86dffb347d30493f4445
URL: https://github.com/llvm/llvm-project/commit/fbd00a47754c1279145b86dffb347d30493f4445
DIFF: https://github.com/llvm/llvm-project/commit/fbd00a47754c1279145b86dffb347d30493f4445.diff
LOG: [Analysis] Use llvm::children and llvm::inverse_children (NFC)
Added:
Modified:
llvm/include/llvm/Analysis/RegionInfoImpl.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/RegionInfoImpl.h b/llvm/include/llvm/Analysis/RegionInfoImpl.h
index ec79b35ae324a5..c5e8821858fd2f 100644
--- a/llvm/include/llvm/Analysis/RegionInfoImpl.h
+++ b/llvm/include/llvm/Analysis/RegionInfoImpl.h
@@ -163,9 +163,7 @@ typename RegionBase<Tr>::BlockT *RegionBase<Tr>::getEnteringBlock() const {
assert(!AllowRepeats && "Unexpected parameter value.");
return DT->getNode(Pred) && !contains(Pred) ? Pred : nullptr;
};
- BlockT *entry = getEntry();
- return find_singleton<BlockT>(make_range(InvBlockTraits::child_begin(entry),
- InvBlockTraits::child_end(entry)),
+ return find_singleton<BlockT>(llvm::inverse_children<BlockT *>(getEntry()),
isEnteringBlock);
}
@@ -177,10 +175,7 @@ bool RegionBase<Tr>::getExitingBlocks(
if (!exit)
return CoverAll;
- for (PredIterTy PI = InvBlockTraits::child_begin(exit),
- PE = InvBlockTraits::child_end(exit);
- PI != PE; ++PI) {
- BlockT *Pred = *PI;
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(exit)) {
if (contains(Pred)) {
Exitings.push_back(Pred);
continue;
@@ -202,8 +197,7 @@ typename RegionBase<Tr>::BlockT *RegionBase<Tr>::getExitingBlock() const {
assert(!AllowRepeats && "Unexpected parameter value.");
return contains(Pred) ? Pred : nullptr;
};
- return find_singleton<BlockT>(make_range(InvBlockTraits::child_begin(exit),
- InvBlockTraits::child_end(exit)),
+ return find_singleton<BlockT>(llvm::inverse_children<BlockT *>(exit),
isContained);
}
@@ -244,16 +238,14 @@ void RegionBase<Tr>::verifyBBInRegion(BlockT *BB) const {
BlockT *entry = getEntry(), *exit = getExit();
- for (BlockT *Succ :
- make_range(BlockTraits::child_begin(BB), BlockTraits::child_end(BB))) {
+ for (BlockT *Succ : llvm::children<BlockT *>(BB)) {
if (!contains(Succ) && exit != Succ)
report_fatal_error("Broken region found: edges leaving the region must go "
"to the exit node!");
}
if (entry != BB) {
- for (BlockT *Pred : make_range(InvBlockTraits::child_begin(BB),
- InvBlockTraits::child_end(BB))) {
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(BB)) {
// Allow predecessors that are unreachable, as these are ignored during
// region analysis.
if (!contains(Pred) && DT->isReachableFromEntry(Pred))
@@ -271,8 +263,7 @@ void RegionBase<Tr>::verifyWalk(BlockT *BB, std::set<BlockT *> *visited) const {
verifyBBInRegion(BB);
- for (BlockT *Succ :
- make_range(BlockTraits::child_begin(BB), BlockTraits::child_end(BB))) {
+ for (BlockT *Succ : llvm::children<BlockT *>(BB)) {
if (Succ != exit && visited->find(Succ) == visited->end())
verifyWalk(Succ, visited);
}
@@ -453,8 +444,7 @@ typename Tr::RegionT *RegionBase<Tr>::getExpandedRegion() const {
RegionT *R = RI->getRegionFor(exit);
if (R->getEntry() != exit) {
- for (BlockT *Pred : make_range(InvBlockTraits::child_begin(getExit()),
- InvBlockTraits::child_end(getExit())))
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(getExit()))
if (!contains(Pred))
return nullptr;
if (Tr::getNumSuccessors(exit) == 1)
@@ -465,8 +455,7 @@ typename Tr::RegionT *RegionBase<Tr>::getExpandedRegion() const {
while (R->getParent() && R->getParent()->getEntry() == exit)
R = R->getParent();
- for (BlockT *Pred : make_range(InvBlockTraits::child_begin(getExit()),
- InvBlockTraits::child_end(getExit()))) {
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(getExit())) {
if (!(contains(Pred) || R->contains(Pred)))
return nullptr;
}
@@ -553,8 +542,7 @@ void RegionInfoBase<Tr>::verifyBBMap(const RegionT *R) const {
template <class Tr>
bool RegionInfoBase<Tr>::isCommonDomFrontier(BlockT *BB, BlockT *entry,
BlockT *exit) const {
- for (BlockT *P : make_range(InvBlockTraits::child_begin(BB),
- InvBlockTraits::child_end(BB))) {
+ for (BlockT *P : llvm::inverse_children<BlockT *>(BB)) {
if (DT->dominates(entry, P) && !DT->dominates(exit, P))
return false;
}
@@ -837,8 +825,7 @@ RegionInfoBase<Tr>::getMaxRegionExit(BlockT *BB) const {
ExitR->getParent()->getEntry() == Exit)
ExitR = ExitR->getParent();
- for (BlockT *Pred : make_range(InvBlockTraits::child_begin(Exit),
- InvBlockTraits::child_end(Exit))) {
+ for (BlockT *Pred : llvm::inverse_children<BlockT *>(Exit)) {
if (!R->contains(Pred) && !ExitR->contains(Pred))
break;
}
More information about the llvm-commits
mailing list