diff options
author | Dan Gohman <gohman@apple.com> | 2008-01-29 12:12:40 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-01-29 12:12:40 +0000 |
commit | 06d31580fb8f94c0f6749ff2e580c44ca95c6fe7 (patch) | |
tree | 03528b466b04fb8115c63a6d871c643200fe57f8 | |
parent | 929391a19a631ad17c62ff262a56836dc5144b38 (diff) | |
download | bcm5719-llvm-06d31580fb8f94c0f6749ff2e580c44ca95c6fe7.tar.gz bcm5719-llvm-06d31580fb8f94c0f6749ff2e580c44ca95c6fe7.zip |
Add comments describing what the loop depth values mean. Also, make a
minor simplification to the loop depth calculation code.
llvm-svn: 46511
-rw-r--r-- | llvm/include/llvm/Analysis/LoopInfo.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h index d80ce3ac26a..93c36e47d8b 100644 --- a/llvm/include/llvm/Analysis/LoopInfo.h +++ b/llvm/include/llvm/Analysis/LoopInfo.h @@ -84,9 +84,12 @@ public: 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 @@ public: 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 @@ public: 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); |