From 507fbe073692b9ba39313406c21e20b53fc56fa3 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Fri, 22 Nov 2013 05:00:48 +0000 Subject: [PATCH] [block-freq] Add a method to loop info for returning all loop latches for a specific loop. We already have a method for returning one loop latch but for some reason no one has committed one for returning loop latches in the case where there are multiple latches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195410 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/LoopInfo.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 62f5acad566..582c97cf569 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -228,6 +228,18 @@ public: /// A latch block is a block that contains a branch back to the header. BlockT *getLoopLatch() const; + /// getLoopLatches - Return all loop latch blocks of this loop. A latch block + /// is a block that contains a branch back to the header. + void getLoopLatches(SmallVectorImpl &LoopLatches) const { + BlockT *H = getHeader(); + typedef GraphTraits > InvBlockTraits; + for (typename InvBlockTraits::ChildIteratorType I = + InvBlockTraits::child_begin(H), + E = InvBlockTraits::child_end(H); I != E; ++I) + if (contains(*I)) + LoopLatches.push_back(*I); + } + //===--------------------------------------------------------------------===// // APIs for updating loop information after changing the CFG //