[llvm] [VPlan] Generalize `VPAllSuccessorsIterator` to support predecessors (PR #178724)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 2 04:51:36 PST 2026
================
@@ -25,90 +25,132 @@ namespace llvm {
// GraphTraits specializations for VPlan Hierarchical Control-Flow Graphs //
//===----------------------------------------------------------------------===//
-/// Iterator to traverse all successors of a VPBlockBase node. This includes the
-/// entry node of VPRegionBlocks. Exit blocks of a region implicitly have their
-/// parent region's successors. This ensures all blocks in a region are visited
-/// before any blocks in a successor region when doing a reverse post-order
-// traversal of the graph. Region blocks themselves traverse only their entries
-// directly and not their successors. Those will be traversed when a region's
-// exiting block is traversed
-template <typename BlockPtrTy>
-class VPAllSuccessorsIterator
- : public iterator_facade_base<VPAllSuccessorsIterator<BlockPtrTy>,
- std::bidirectional_iterator_tag,
- VPBlockBase> {
+/// Iterator to traverse all successors/predecessors of a VPBlockBase node, such
+/// that:
+///
+/// A
+/// |
+/// +-----+ <- Region R
+/// | b |
+/// | |
+/// | ... |
+/// | |
+/// | e |
+/// +-----+
+/// |
+/// B
+///
+/// children(A) == {R} ; Forward == true
+/// children(R) == {b} ; Forward == true
+/// children(e) == {B} ; Forward == true
+///
+/// children(B) == {R} ; Forward == false
+/// children(R) == {e} ; Forward == false
+/// children(b) == {A} ; Forward == false
+///
+/// This ensures that all blocks of the region are visited before continuing
----------------
fhahn wrote:
It looks like this dropped the preceding explanation (`Exit blocks of a region implicitly have their parent region's successors.`)
https://github.com/llvm/llvm-project/pull/178724
More information about the llvm-commits
mailing list