[llvm-commits] [llvm] r46511 - /llvm/trunk/include/llvm/Analysis/LoopInfo.h

Dan Gohman djg at cray.com
Tue Jan 29 04:12:40 PST 2008


Author: djg
Date: Tue Jan 29 06:12:40 2008
New Revision: 46511

URL: http://llvm.org/viewvc/llvm-project?rev=46511&view=rev
Log:
Add comments describing what the loop depth values mean. Also, make a
minor simplification to the loop depth calculation code.

Modified:
    llvm/trunk/include/llvm/Analysis/LoopInfo.h

Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=46511&r1=46510&r2=46511&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Tue Jan 29 06:12:40 2008
@@ -84,9 +84,12 @@
       delete SubLoops[i];
   }
 
+  /// getLoopDepth - Return the nesting level of this loop.  An outer-most
+  /// loop has depth 1, for consistency with loop depth values used for basic
+  /// blocks, where depth 0 is used for blocks not inside any loops.
   unsigned getLoopDepth() const {
-    unsigned D = 0;
-    for (const LoopBase<BlockT> *CurLoop = this; CurLoop;
+    unsigned D = 1;
+    for (const LoopBase<BlockT> *CurLoop = ParentLoop; CurLoop;
          CurLoop = CurLoop->ParentLoop)
       ++D;
     return D;
@@ -603,7 +606,8 @@
     return getLoopFor(BB);
   }
   
-  /// getLoopDepth - Return the loop nesting level of the specified block...
+  /// getLoopDepth - Return the loop nesting level of the specified block.  A
+  /// depth of 0 means the block is not inside any loop.
   ///
   unsigned getLoopDepth(const BlockT *BB) const {
     const LoopBase<BlockT> *L = getLoopFor(BB);
@@ -898,7 +902,8 @@
     return LI->getLoopFor(BB);
   }
 
-  /// getLoopDepth - Return the loop nesting level of the specified block...
+  /// getLoopDepth - Return the loop nesting level of the specified block.  A
+  /// depth of 0 means the block is not inside any loop.
   ///
   inline unsigned getLoopDepth(const BasicBlock *BB) const {
     return LI->getLoopDepth(BB);





More information about the llvm-commits mailing list