[llvm] ac0b601 - [Analysis] Use llvm::succ_empty and llvm::successors (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 23:46:37 PST 2024


Author: Kazu Hirata
Date: 2024-01-26T23:46:25-08:00
New Revision: ac0b6016af5a00865ce0c3b4f1d007f8ac96b8eb

URL: https://github.com/llvm/llvm-project/commit/ac0b6016af5a00865ce0c3b4f1d007f8ac96b8eb
DIFF: https://github.com/llvm/llvm-project/commit/ac0b6016af5a00865ce0c3b4f1d007f8ac96b8eb.diff

LOG: [Analysis] Use llvm::succ_empty and llvm::successors (NFC)

Added: 
    

Modified: 
    llvm/lib/Analysis/LoopInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 59c96a3371e87a..ab2e99f98170aa 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -816,20 +816,19 @@ Loop *UnloopUpdater::getNearestLoop(BasicBlock *BB, Loop *BBLoop) {
     NearLoop = SubloopParents.insert({Subloop, &Unloop}).first->second;
   }
 
-  succ_iterator I = succ_begin(BB), E = succ_end(BB);
-  if (I == E) {
+  if (succ_empty(BB)) {
     assert(!Subloop && "subloop blocks must have a successor");
     NearLoop = nullptr; // unloop blocks may now exit the function.
   }
-  for (; I != E; ++I) {
-    if (*I == BB)
+  for (BasicBlock *Succ : successors(BB)) {
+    if (Succ == BB)
       continue; // self loops are uninteresting
 
-    Loop *L = LI->getLoopFor(*I);
+    Loop *L = LI->getLoopFor(Succ);
     if (L == &Unloop) {
       // This successor has not been processed. This path must lead to an
       // irreducible backedge.
-      assert((FoundIB || !DFS.hasPostorder(*I)) && "should have seen IB");
+      assert((FoundIB || !DFS.hasPostorder(Succ)) && "should have seen IB");
       FoundIB = true;
     }
     if (L != &Unloop && Unloop.contains(L)) {


        


More information about the llvm-commits mailing list