[llvm] r206858 - blockfreq: Use a pointer for ContainingLoop too
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Apr 21 20:31:45 PDT 2014
Author: dexonsmith
Date: Mon Apr 21 22:31:44 2014
New Revision: 206858
URL: http://llvm.org/viewvc/llvm-project?rev=206858&view=rev
Log:
blockfreq: Use a pointer for ContainingLoop too
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=206858&r1=206857&r2=206858&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h Mon Apr 21 22:31:44 2014
@@ -958,16 +958,25 @@ public:
/// \brief Index of loop information.
struct WorkingData {
LoopData *Loop; ///< The loop this block is the header of.
- BlockNode ContainingLoop; ///< The block whose loop this block is inside.
- bool IsPackaged; ///< Has ContainingLoop been packaged up?
+ LoopData *ContainingLoop; ///< The block whose loop this block is inside.
BlockMass Mass; ///< Mass distribution from the entry block.
- WorkingData() : Loop(nullptr), IsPackaged(false) {}
+ WorkingData() : Loop(nullptr), ContainingLoop(nullptr) {}
- bool hasLoopHeader() const { return ContainingLoop.isValid(); }
+ bool hasLoopHeader() const { return ContainingLoop; }
bool isLoopHeader() const { return Loop; }
- /// \brief Has this block's loop been packaged up?
+ BlockNode getContainingHeader() const {
+ if (ContainingLoop)
+ return ContainingLoop->Header;
+ return BlockNode();
+ }
+
+ /// \brief Has ContainingLoop been packaged up?
+ bool isPackaged() const {
+ return ContainingLoop && ContainingLoop->IsPackaged;
+ }
+ /// \brief Has Loop been packaged up?
bool isAPackage() const { return Loop && Loop->IsPackaged; }
};
@@ -1041,7 +1050,7 @@ public:
/// \brief Loop data: see initializeLoops().
std::vector<WorkingData> Working;
- /// \brief Indexed information about packaged loops.
+ /// \brief Indexed information about loops.
std::vector<std::unique_ptr<LoopData>> PackagedLoops;
/// \brief Add all edges out of a packaged loop to the distribution.
@@ -1452,7 +1461,7 @@ template <class BT> void BlockFrequencyI
const auto &HeaderData = Working[Header.Index];
assert(HeaderData.isLoopHeader());
- Working[Index].ContainingLoop = Header;
+ Working[Index].ContainingLoop = HeaderData.Loop;
HeaderData.Loop->Members.push_back(Index);
DEBUG(dbgs() << " - loop = " << getBlockName(Header)
<< ": member = " << getBlockName(Index) << "\n");
Modified: llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp?rev=206858&r1=206857&r2=206858&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp (original)
+++ llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp Mon Apr 21 22:31:44 2014
@@ -630,11 +630,11 @@ static void cleanup(BlockFrequencyInfoIm
static BlockNode getPackagedNode(const BlockFrequencyInfoImplBase &BFI,
const BlockNode &Node) {
assert(Node.isValid());
- if (!BFI.Working[Node.Index].IsPackaged)
+ if (!BFI.Working[Node.Index].isPackaged())
return Node;
- if (!BFI.Working[Node.Index].ContainingLoop.isValid())
+ if (!BFI.Working[Node.Index].isAPackage())
return Node;
- return getPackagedNode(BFI, BFI.Working[Node.Index].ContainingLoop);
+ return getPackagedNode(BFI, BFI.Working[Node.Index].getContainingHeader());
}
/// \brief Get the appropriate mass for a possible pseudo-node loop package.
@@ -645,7 +645,7 @@ static BlockNode getPackagedNode(const B
static BlockMass &getPackageMass(BlockFrequencyInfoImplBase &BFI,
const BlockNode &Node) {
assert(Node.isValid());
- assert(!BFI.Working[Node.Index].IsPackaged);
+ assert(!BFI.Working[Node.Index].isPackaged());
if (!BFI.Working[Node.Index].isAPackage())
return BFI.Working[Node.Index].Mass;
@@ -681,7 +681,7 @@ void BlockFrequencyInfoImplBase::addToDi
BlockNode Resolved = getPackagedNode(*this, Succ);
assert(Resolved != LoopHead);
- if (Working[Resolved.Index].ContainingLoop != LoopHead) {
+ if (Working[Resolved.Index].getContainingHeader() != LoopHead) {
DEBUG(debugSuccessor(" exit ", Resolved));
Dist.addExit(Resolved, Weight);
return;
@@ -746,10 +746,10 @@ void BlockFrequencyInfoImplBase::package
DEBUG(dbgs() << "packaging-loop: " << getBlockName(LoopHead) << "\n");
auto &PackagedLoop = getLoopPackage(LoopHead);
PackagedLoop.IsPackaged = true;
- for (const BlockNode &M : PackagedLoop.Members) {
- DEBUG(dbgs() << " - node: " << getBlockName(M.Index) << "\n");
- Working[M.Index].IsPackaged = true;
- }
+ DEBUG(for (const BlockNode &M
+ : PackagedLoop.Members) {
+ dbgs() << " - node: " << getBlockName(M.Index) << "\n";
+ });
}
void BlockFrequencyInfoImplBase::distributeMass(const BlockNode &Source,
More information about the llvm-commits
mailing list