[llvm] 393f4e8 - [Analysis][Docs] Parents of loops documentation.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 21 15:14:20 PST 2020


Author: Stefanos Baziotis
Date: 2020-02-21T17:11:53-06:00
New Revision: 393f4e8ac263d0debecb571bbab69bcf31474cdb

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

LOG: [Analysis][Docs] Parents of loops documentation.

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

Added: 
    

Modified: 
    llvm/docs/LoopTerminology.rst
    llvm/include/llvm/Analysis/LoopInfo.h

Removed: 
    


################################################################################
diff  --git a/llvm/docs/LoopTerminology.rst b/llvm/docs/LoopTerminology.rst
index 991282e50519..e33a019da3c6 100644
--- a/llvm/docs/LoopTerminology.rst
+++ b/llvm/docs/LoopTerminology.rst
@@ -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

diff  --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h
index a01045124c7b..824488e9ead8 100644
--- a/llvm/include/llvm/Analysis/LoopInfo.h
+++ b/llvm/include/llvm/Analysis/LoopInfo.h
@@ -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.


        


More information about the llvm-commits mailing list