Index: llvm/docs/LoopTerminology.rst =================================================================== --- llvm/docs/LoopTerminology.rst +++ llvm/docs/LoopTerminology.rst @@ -117,6 +117,11 @@ } while (..) } +Parent Loop - A loop is either a top level loop, that is it +is not enclosed in any other loop or it is a sub-loop of another. +A parent of a loop is the innermost loop in which it is enclosed in. +A top level loop does not have a parent. + LoopInfo ======== Index: llvm/include/llvm/Analysis/LoopInfo.h =================================================================== --- llvm/include/llvm/Analysis/LoopInfo.h +++ llvm/include/llvm/Analysis/LoopInfo.h @@ -103,6 +103,13 @@ return D; } BlockT *getHeader() const { return getBlocks().front(); } + /// Return the parent loop if it exists or nullptr otherwise. + + /// 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 in. LoopT *getParentLoop() const { return ParentLoop; } /// This is a raw interface for bypassing addChildLoop.