From 6f1f9f4c7f8a5de44c2bcd610fa909f17860fbd1 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 25 Apr 2014 04:30:06 +0000 Subject: [PATCH] blockfreq: Use a std::list for Loops As pointed out by David Blaikie in code review, a `std::list` is simpler than a `std::vector>`. Another option is a `std::deque` (which allocates in chunks), but I'd like to leave open the option of inserting in the middle of the sequence for handling irreducible control flow on the fly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207177 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/BlockFrequencyInfoImpl.h | 9 +++++---- lib/Analysis/BlockFrequencyInfoImpl.cpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/include/llvm/Analysis/BlockFrequencyInfoImpl.h index da39ba0e47f..310b23f0ea4 100644 --- a/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -23,6 +23,7 @@ #include "llvm/Support/raw_ostream.h" #include #include +#include #define DEBUG_TYPE "block-freq" @@ -1051,7 +1052,7 @@ public: std::vector Working; /// \brief Indexed information about loops. - std::vector> Loops; + std::list Loops; /// \brief Add all edges out of a packaged loop to the distribution. /// @@ -1438,8 +1439,8 @@ template void BlockFrequencyInfoImpl::initializeLoops() { BlockNode Header = getNode(Loop->getHeader()); assert(Header.isValid()); - Loops.emplace_back(new LoopData(Header)); - Working[Header.Index].Loop = Loops.back().get(); + Loops.emplace_back(Header); + Working[Header.Index].Loop = &Loops.back(); DEBUG(dbgs() << " - loop = " << getBlockName(Header) << "\n"); } @@ -1471,7 +1472,7 @@ template void BlockFrequencyInfoImpl::initializeLoops() { template void BlockFrequencyInfoImpl::computeMassInLoops() { // Visit loops with the deepest first, and the top-level loops last. for (const auto &L : make_range(Loops.rbegin(), Loops.rend())) - computeMassInLoop(L->Header); + computeMassInLoop(L.Header); } template diff --git a/lib/Analysis/BlockFrequencyInfoImpl.cpp b/lib/Analysis/BlockFrequencyInfoImpl.cpp index 29a4117c130..42c674983c4 100644 --- a/lib/Analysis/BlockFrequencyInfoImpl.cpp +++ b/lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -602,7 +602,7 @@ void BlockFrequencyInfoImplBase::clear() { // does not actually clear heap storage. std::vector().swap(Freqs); std::vector().swap(Working); - std::vector>().swap(Loops); + Loops.clear(); } /// \brief Clear all memory not needed downstream. -- 2.34.1