Skip to content

Commit

Permalink
[Analysis][Docs] Parents of loops documentation.
Browse files Browse the repository at this point in the history
Recently I had to use it and although one assumes it returns null if
there's no parent loop, I think it helps to doc it.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D74890
  • Loading branch information
baziotis authored and Meinersbur committed Feb 21, 2020
1 parent 215a311 commit 393f4e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/docs/LoopTerminology.rst
Expand Up @@ -43,6 +43,9 @@ Note that there are some important implications of this definition:
* Any two loops are either fully disjoint (no intersecting blocks), or
one must be a sub-loop of the other.

* Loops in a function form a forest. One implication of this fact
is that a loop either has no parent or a single parent.

A loop may have an arbitrary number of exits, both explicit (via
control flow) and implicit (via throwing calls which transfer control
out of the containing function). There is no special requirement on
Expand Down
8 changes: 8 additions & 0 deletions llvm/include/llvm/Analysis/LoopInfo.h
Expand Up @@ -103,6 +103,14 @@ template <class BlockT, class LoopT> class LoopBase {
return D;
}
BlockT *getHeader() const { return getBlocks().front(); }
/// Return the parent loop if it exists or nullptr for top
/// level loops.

/// A loop is either top-level in a function (that is, it is not
/// contained in any other loop) or it is entirely enclosed in
/// some other loop.
/// If a loop is top-level, it has no parent, otherwise its
/// parent is the innermost loop in which it is enclosed.
LoopT *getParentLoop() const { return ParentLoop; }

/// This is a raw interface for bypassing addChildLoop.
Expand Down

0 comments on commit 393f4e8

Please sign in to comment.