[llvm] ecdd640 - [LoopInfo] Avoid a throwaway vector in getLoopsInPreorder. NFC (#207607)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 5 13:24:38 PDT 2026


Author: Fangrui Song
Date: 2026-07-05T20:24:34Z
New Revision: ecdd6403fd213f90243a3d354d4db3483b89471f

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

LOG: [LoopInfo] Avoid a throwaway vector in getLoopsInPreorder. NFC (#207607)

We can append each root and walk its inner loops directly into the
result.

Added: 
    

Modified: 
    llvm/include/llvm/Support/GenericLoopInfoImpl.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/GenericLoopInfoImpl.h b/llvm/include/llvm/Support/GenericLoopInfoImpl.h
index c39df269dd842..4666f4dac9cb6 100644
--- a/llvm/include/llvm/Support/GenericLoopInfoImpl.h
+++ b/llvm/include/llvm/Support/GenericLoopInfoImpl.h
@@ -618,9 +618,8 @@ LoopInfoBase<BlockT, LoopT>::getLoopsInPreorder() const {
   // FIXME: If we change the order of LoopInfo we will want to remove the
   // reverse here.
   for (LoopT *RootL : reverse(*this)) {
-    auto PreOrderLoopsInRootL = RootL->getLoopsInPreorder();
-    PreOrderLoops.append(PreOrderLoopsInRootL.begin(),
-                         PreOrderLoopsInRootL.end());
+    PreOrderLoops.push_back(RootL);
+    LoopT::getInnerLoopsInPreorder(*RootL, PreOrderLoops);
   }
 
   return PreOrderLoops;


        


More information about the llvm-commits mailing list