[llvm] r207182 - blockfreq: Store the header with the members
Duncan P. N. Exon Smith
dexonsmith at apple.com
Thu Apr 24 21:38:10 PDT 2014
Author: dexonsmith
Date: Thu Apr 24 23:38:09 2014
New Revision: 207182
URL: http://llvm.org/viewvc/llvm-project?rev=207182&view=rev
Log:
blockfreq: Store the header with the members
<rdar://problem/14292693>
Modified:
llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h
llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp
Modified: llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h?rev=207182&r1=207181&r2=207182&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h Thu Apr 24 23:38:09 2014
@@ -16,6 +16,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/ADT/iterator_range.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/Support/BlockFrequency.h"
#include "llvm/Support/BranchProbability.h"
@@ -946,18 +947,25 @@ public:
typedef SmallVector<std::pair<BlockNode, BlockMass>, 4> ExitMap;
typedef SmallVector<BlockNode, 4> MemberList;
LoopData *Parent; ///< The parent loop.
- BlockNode Header; ///< Header.
bool IsPackaged; ///< Whether this has been packaged.
ExitMap Exits; ///< Successor edges (and weights).
- MemberList Members; ///< Members of the loop.
+ MemberList Nodes; ///< Header and the members of the loop.
BlockMass BackedgeMass; ///< Mass returned to loop header.
BlockMass Mass;
Float Scale;
LoopData(LoopData *Parent, const BlockNode &Header)
- : Parent(Parent), Header(Header), IsPackaged(false) {}
- bool isHeader(const BlockNode &Node) const { return Node == Header; }
- BlockNode getHeader() const { return Header; }
+ : Parent(Parent), IsPackaged(false), Nodes(1, Header) {}
+ bool isHeader(const BlockNode &Node) const { return Node == Nodes[0]; }
+ BlockNode getHeader() const { return Nodes[0]; }
+
+ MemberList::const_iterator members_begin() const {
+ return Nodes.begin() + 1;
+ }
+ MemberList::const_iterator members_end() const { return Nodes.end(); }
+ iterator_range<MemberList::const_iterator> members() const {
+ return make_range(members_begin(), members_end());
+ }
};
/// \brief Index of loop information.
@@ -1463,7 +1471,7 @@ template <class BT> void BlockFrequencyI
if (Working[Index].isLoopHeader()) {
LoopData *ContainingLoop = Working[Index].getContainingLoop();
if (ContainingLoop)
- ContainingLoop->Members.push_back(Index);
+ ContainingLoop->Nodes.push_back(Index);
continue;
}
@@ -1478,7 +1486,7 @@ template <class BT> void BlockFrequencyI
assert(HeaderData.isLoopHeader());
Working[Index].Loop = HeaderData.Loop;
- HeaderData.Loop->Members.push_back(Index);
+ HeaderData.Loop->Nodes.push_back(Index);
DEBUG(dbgs() << " - loop = " << getBlockName(Header)
<< ": member = " << getBlockName(Index) << "\n");
}
@@ -1499,7 +1507,7 @@ void BlockFrequencyInfoImpl<BT>::compute
Working[Loop.getHeader().Index].Mass = BlockMass::getFull();
propagateMassToSuccessors(&Loop, Loop.getHeader());
- for (const BlockNode &M : Loop.Members)
+ for (const BlockNode &M : Loop.members())
propagateMassToSuccessors(&Loop, M);
computeLoopScale(Loop);
Modified: llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp?rev=207182&r1=207181&r2=207182&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp (original)
+++ llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp Thu Apr 24 23:38:09 2014
@@ -746,7 +746,7 @@ void BlockFrequencyInfoImplBase::package
DEBUG(dbgs() << "packaging-loop: " << getBlockName(Loop.getHeader()) << "\n");
Loop.IsPackaged = true;
DEBUG(for (const BlockNode &M
- : Loop.Members) {
+ : Loop.members()) {
dbgs() << " - node: " << getBlockName(M.Index) << "\n";
});
}
@@ -859,7 +859,7 @@ static void unwrapLoopPackage(BlockFrequ
// Propagate the head scale through the loop. Since members are visited in
// RPO, the head scale will be updated by the loop scale first, and then the
// final head scale will be used for updated the rest of the members.
- for (const BlockNode &M : LoopPackage.Members) {
+ for (const BlockNode &M : LoopPackage.members()) {
const FrequencyData &HeadData = BFI.Freqs[Head.Index];
FrequencyData &Freqs = BFI.Freqs[M.Index];
Float NewFreq = Freqs.Floating * HeadData.Floating;
More information about the llvm-commits
mailing list