blockfreq: Separate unwrapLoops() from finalizeMetrics()

<rdar://problem/14292693>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207185 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2014-04-25 04:38:17 +00:00
parent e839ab26ba
commit 3475765998
2 changed files with 15 additions and 7 deletions

View File

@ -1141,10 +1141,13 @@ public:
/// \brief Package up a loop.
void packageLoop(LoopData &Loop);
/// \brief Unwrap loops.
void unwrapLoops();
/// \brief Finalize frequency metrics.
///
/// Unwraps loop packages, calculates final frequencies, and cleans up
/// no-longer-needed data structures.
/// Calculates final frequencies and cleans up no-longer-needed data
/// structures.
void finalizeMetrics();
/// \brief Clear all memory.
@ -1434,6 +1437,7 @@ void BlockFrequencyInfoImpl<BT>::doFunction(const FunctionT *F,
// the full function.
computeMassInLoops();
computeMassInFunction();
unwrapLoops();
finalizeMetrics();
}

View File

@ -846,20 +846,24 @@ static void unwrapLoopPackage(BlockFrequencyInfoImplBase &BFI,
}
}
void BlockFrequencyInfoImplBase::finalizeMetrics() {
void BlockFrequencyInfoImplBase::unwrapLoops() {
// Set initial frequencies from loop-local masses.
for (size_t Index = 0; Index < Working.size(); ++Index)
Freqs[Index].Floating = Working[Index].Mass.toFloat();
for (size_t Index = 0; Index < Working.size(); ++Index) {
if (Working[Index].isLoopHeader())
unwrapLoopPackage(*this, BlockNode(Index));
}
}
void BlockFrequencyInfoImplBase::finalizeMetrics() {
// Unwrap loop packages in reverse post-order, tracking min and max
// frequencies.
auto Min = Float::getLargest();
auto Max = Float::getZero();
for (size_t Index = 0; Index < Working.size(); ++Index) {
if (Working[Index].isLoopHeader())
unwrapLoopPackage(*this, BlockNode(Index));
// Update max scale.
// Update min/max scale.
Min = std::min(Min, Freqs[Index].Floating);
Max = std::max(Max, Freqs[Index].Floating);
}