[llvm] r276835 - refactor code in verifyLoop: NFC.
Sebastian Pop via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 26 21:36:06 PDT 2016
Author: spop
Date: Tue Jul 26 23:36:06 2016
New Revision: 276835
URL: http://llvm.org/viewvc/llvm-project?rev=276835&view=rev
Log:
refactor code in verifyLoop: NFC.
Use std::any_of as requested in https://reviews.llvm.org/D22816
Modified:
llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h
Modified: llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h?rev=276835&r1=276834&r2=276835&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h Tue Jul 26 23:36:06 2016
@@ -240,31 +240,23 @@ void LoopBase<BlockT, LoopT>::verifyLoop
// Check the individual blocks.
for ( ; BI != BE; ++BI) {
BlockT *BB = *BI;
- bool HasInsideLoopSuccs = false;
- bool HasInsideLoopPreds = false;
- SmallVector<BlockT *, 2> OutsideLoopPreds;
- typedef GraphTraits<BlockT*> BlockTraits;
- for (typename BlockTraits::ChildIteratorType SI =
- BlockTraits::child_begin(BB), SE = BlockTraits::child_end(BB);
- SI != SE; ++SI)
- if (contains(*SI)) {
- HasInsideLoopSuccs = true;
- break;
- }
- assert(HasInsideLoopSuccs && "Loop block has no in-loop successors!");
+ assert(std::any_of(GraphTraits<BlockT*>::child_begin(BB),
+ GraphTraits<BlockT*>::child_end(BB),
+ [&](BlockT *B){return contains(B);}) &&
+ "Loop block has no in-loop successors!");
+
+ assert(std::any_of(GraphTraits<Inverse<BlockT*> >::child_begin(BB),
+ GraphTraits<Inverse<BlockT*> >::child_end(BB),
+ [&](BlockT *B){return contains(B);}) &&
+ "Loop block has no in-loop predecessors!");
- typedef GraphTraits<Inverse<BlockT*> > InvBlockTraits;
- for (typename InvBlockTraits::ChildIteratorType PI =
- InvBlockTraits::child_begin(BB), PE = InvBlockTraits::child_end(BB);
- PI != PE; ++PI) {
- BlockT *N = *PI;
- if (contains(N))
- HasInsideLoopPreds = true;
- else
- OutsideLoopPreds.push_back(N);
- }
- assert(HasInsideLoopPreds && "Loop block has no in-loop predecessors!");
+ SmallVector<BlockT *, 2> OutsideLoopPreds;
+ std::for_each(GraphTraits<Inverse<BlockT*> >::child_begin(BB),
+ GraphTraits<Inverse<BlockT*> >::child_end(BB),
+ [&](BlockT *B){if (!contains(B))
+ OutsideLoopPreds.push_back(B);
+ });
if (BB == getHeader()) {
assert(!OutsideLoopPreds.empty() && "Loop is unreachable!");
More information about the llvm-commits
mailing list