LLVM 23.0.0git
llvm::LoopBlocksTraversal Class Reference

Traverse the blocks in a loop using a depth-first search. More...

#include "llvm/Analysis/LoopIterator.h"

Inheritance diagram for llvm::LoopBlocksTraversal:
[legend]

Public Member Functions

 LoopBlocksTraversal (LoopBlocksDFS &Storage, const LoopInfo *LInfo)
iterator begin ()
 Postorder traversal over the graph.
iterator end ()
bool insertEdge (std::optional< BasicBlock * >, BasicBlock *BB)
 Called upon reaching a block via a CFG edge.
void finishPostorder (BasicBlock *BB)
 Called each time the iterator advances, indicating a block's postorder.
Public Member Functions inherited from llvm::PostOrderTraversalBase< LoopBlocksTraversal, GraphTraits< Function * > >
iterator begin ()
iterator end ()
bool insertEdge (std::optional< NodeRef > From, NodeRef To)
 Add edge and return whether To should be visited.
void finishPostorder (NodeRef)
 Callback just before the iterator moves to the next block.

Additional Inherited Members

Protected Member Functions inherited from llvm::PostOrderTraversalBase< LoopBlocksTraversal, GraphTraits< Function * > >
 PostOrderTraversalBase ()=default
LoopBlocksTraversalderived ()
void init (NodeRef Start)
 Initialize post-order traversal at given start node.

Detailed Description

Traverse the blocks in a loop using a depth-first search.

Definition at line 190 of file LoopIterator.h.

Constructor & Destructor Documentation

◆ LoopBlocksTraversal()

llvm::LoopBlocksTraversal::LoopBlocksTraversal ( LoopBlocksDFS & Storage,
const LoopInfo * LInfo )
inline

Definition at line 197 of file LoopIterator.h.

Member Function Documentation

◆ begin()

iterator llvm::LoopBlocksTraversal::begin ( )
inline

Postorder traversal over the graph.

This only needs to be done once. PostOrderTraversalBase "automatically" calls back to insertEdge and finishPostorder to record the DFS result.

Definition at line 203 of file LoopIterator.h.

References assert(), llvm::PostOrderTraversalBase< DerivedT, GraphTraits >::begin(), and llvm::PostOrderTraversalBase< LoopBlocksTraversal, GraphTraits< Function * > >::init().

◆ end()

iterator llvm::LoopBlocksTraversal::end ( )
inline

◆ finishPostorder()

void llvm::LoopBlocksTraversal::finishPostorder ( BasicBlock * BB)
inline

Called each time the iterator advances, indicating a block's postorder.

Definition at line 224 of file LoopIterator.h.

References assert().

◆ insertEdge()

bool llvm::LoopBlocksTraversal::insertEdge ( std::optional< BasicBlock * > ,
BasicBlock * BB )
inline

Called upon reaching a block via a CFG edge.

If this block is contained in the loop and has not been visited, then mark it preorder visited and return true (i.e., traverse the edge).

TODO: If anyone is interested, we could record preorder numbers here.

Definition at line 216 of file LoopIterator.h.


The documentation for this class was generated from the following file: