From 3475765998020c9dcc2d70248f7f7a215c2d1a70 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 25 Apr 2014 04:38:17 +0000 Subject: [PATCH] blockfreq: Separate unwrapLoops() from finalizeMetrics() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207185 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/BlockFrequencyInfoImpl.h | 8 ++++++-- lib/Analysis/BlockFrequencyInfoImpl.cpp | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/include/llvm/Analysis/BlockFrequencyInfoImpl.h index e6f08bb04e4..81456636308 100644 --- a/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -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::doFunction(const FunctionT *F, // the full function. computeMassInLoops(); computeMassInFunction(); + unwrapLoops(); finalizeMetrics(); } diff --git a/lib/Analysis/BlockFrequencyInfoImpl.cpp b/lib/Analysis/BlockFrequencyInfoImpl.cpp index d58a7435a35..6b65bf6478e 100644 --- a/lib/Analysis/BlockFrequencyInfoImpl.cpp +++ b/lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -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); } -- 2.34.1