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.