diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-04-25 04:30:06 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-04-25 04:30:06 +0000 |
| commit | fc7dc930318ced3246bdab82068910da1059a4e6 (patch) | |
| tree | b05dec436858620ce55e42e9509159524a555451 /llvm | |
| parent | e6cb63e471c56fa7e90916ec81da76a2604e388f (diff) | |
| download | bcm5719-llvm-fc7dc930318ced3246bdab82068910da1059a4e6.tar.gz bcm5719-llvm-fc7dc930318ced3246bdab82068910da1059a4e6.zip | |
blockfreq: Use a std::list for Loops
As pointed out by David Blaikie in code review, a `std::list<T>` is
simpler than a `std::vector<std::unique_ptr<T>>`. Another option is a
`std::deque<T>` (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.
<rdar://problem/14292693>
llvm-svn: 207177
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h | 9 | ||||
| -rw-r--r-- | llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h index da39ba0e47f..310b23f0ea4 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -23,6 +23,7 @@ #include "llvm/Support/raw_ostream.h" #include <string> #include <vector> +#include <list> #define DEBUG_TYPE "block-freq" @@ -1051,7 +1052,7 @@ public: std::vector<WorkingData> Working; /// \brief Indexed information about loops. - std::vector<std::unique_ptr<LoopData>> Loops; + std::list<LoopData> Loops; /// \brief Add all edges out of a packaged loop to the distribution. /// @@ -1438,8 +1439,8 @@ template <class BT> void BlockFrequencyInfoImpl<BT>::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 <class BT> void BlockFrequencyInfoImpl<BT>::initializeLoops() { template <class BT> void BlockFrequencyInfoImpl<BT>::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 <class BT> diff --git a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp index 29a4117c130..42c674983c4 100644 --- a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp +++ b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -602,7 +602,7 @@ void BlockFrequencyInfoImplBase::clear() { // does not actually clear heap storage. std::vector<FrequencyData>().swap(Freqs); std::vector<WorkingData>().swap(Working); - std::vector<std::unique_ptr<LoopData>>().swap(Loops); + Loops.clear(); } /// \brief Clear all memory not needed downstream. |

