[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:37 PST 2026
================
@@ -285,23 +331,19 @@ template <> struct GraphTraits<const VPBlockBase *> {
}
};
-/// Inverse graph traits are not implemented yet.
-/// TODO: Implement a version of VPBlockNonRecursiveTraversalWrapper to traverse
-/// predecessors recursively through regions.
template <> struct GraphTraits<Inverse<VPBlockBase *>> {
using NodeRef = VPBlockBase *;
- using ChildIteratorType = SmallVectorImpl<VPBlockBase *>::iterator;
+ using ChildIteratorType =
+ VPImmediateHierarchicalChildrenIterator<VPBlockBase *, /*Forward=*/false>;
- static NodeRef getEntryNode(Inverse<NodeRef> B) {
- llvm_unreachable("not implemented");
- }
+ static NodeRef getEntryNode(Inverse<NodeRef> B) { return B.Graph; }
static inline ChildIteratorType child_begin(NodeRef N) {
- llvm_unreachable("not implemented");
+ return ChildIteratorType{N};
----------------
fhahn wrote:
If possible, LLVM recommends using () for constructors (https://llvm.org/docs/CodingStandards.html#do-not-use-braced-initializer-lists-to-call-a-constructor)
```suggestion
return ChildIteratorType(N);
```
https://github.com/llvm/llvm-project/pull/178724
More information about the llvm-commits
mailing list