2222#include " lld/Common/ErrorHandler.h"
2323#include " llvm/ADT/CachedHashString.h"
2424#include " llvm/ADT/DenseMap.h"
25- #include " llvm/ADT/DenseSet .h"
25+ #include " llvm/ADT/MapVector .h"
2626#include " llvm/ADT/SetVector.h"
2727#include " llvm/ADT/SmallSet.h"
2828#include " llvm/ADT/SmallVector.h"
3535#include " llvm/Support/VirtualFileSystem.h"
3636#include < memory>
3737#include < optional>
38+ #include < set>
3839
3940#define DEBUG_TYPE " bp-section-orderer"
4041
@@ -60,7 +61,7 @@ template <class D> struct BPOrderer {
6061 bool forDataCompression,
6162 bool compressionSortStartupFunctions, bool verbose,
6263 llvm::ArrayRef<Section *> sections,
63- const DenseMap<CachedHashStringRef, DenseSet <unsigned >>
64+ const DenseMap<CachedHashStringRef, std::set <unsigned >>
6465 &rootSymbolToSectionIdxs)
6566 -> llvm::DenseMap<const Section *, int>;
6667
@@ -77,7 +78,7 @@ static SmallVector<std::pair<unsigned, UtilityNodes>> getUnsForCompression(
7778 ArrayRef<const typename D::Section *> sections,
7879 const DenseMap<const void *, uint64_t > §ionToIdx,
7980 ArrayRef<unsigned > sectionIdxs,
80- DenseMap<unsigned , SmallVector<unsigned >> *duplicateSectionIdxs,
81+ DenseMap<unsigned , SmallVector<unsigned , 0 >> *duplicateSectionIdxs,
8182 BPFunctionNode::UtilityNodeT &maxUN) {
8283 TimeTraceScope timeScope (" Build nodes for compression" );
8384
@@ -92,7 +93,7 @@ static SmallVector<std::pair<unsigned, UtilityNodes>> getUnsForCompression(
9293 hashes.clear ();
9394 }
9495
95- DenseMap <uint64_t , unsigned > hashFrequency;
96+ MapVector <uint64_t , unsigned > hashFrequency;
9697 for (auto &[sectionIdx, hashes] : sectionHashes)
9798 for (auto hash : hashes)
9899 ++hashFrequency[hash];
@@ -161,7 +162,7 @@ auto BPOrderer<D>::computeOrder(
161162 StringRef profilePath, bool forFunctionCompression, bool forDataCompression,
162163 bool compressionSortStartupFunctions, bool verbose,
163164 ArrayRef<Section *> sections,
164- const DenseMap<CachedHashStringRef, DenseSet <unsigned >>
165+ const DenseMap<CachedHashStringRef, std::set <unsigned >>
165166 &rootSymbolToSectionIdxs) -> DenseMap<const Section *, int > {
166167 TimeTraceScope timeScope (" Setup Balanced Partitioning" );
167168 DenseMap<const void *, uint64_t > sectionToIdx;
@@ -185,7 +186,7 @@ auto BPOrderer<D>::computeOrder(
185186 }
186187 auto &traces = reader->getTemporalProfTraces ();
187188
188- DenseMap <unsigned , BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
189+ MapVector <unsigned , BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
189190 for (size_t traceIdx = 0 ; traceIdx < traces.size (); traceIdx++) {
190191 uint64_t currentSize = 0 , cutoffSize = 1 ;
191192 size_t cutoffTimestamp = 1 ;
@@ -262,7 +263,7 @@ auto BPOrderer<D>::computeOrder(
262263
263264 // Map a section index (order directly) to a list of duplicate section indices
264265 // (not ordered directly).
265- DenseMap<unsigned , SmallVector<unsigned >> duplicateSectionIdxs;
266+ DenseMap<unsigned , SmallVector<unsigned , 0 >> duplicateSectionIdxs;
266267 auto unsForFunctionCompression = getUnsForCompression<D>(
267268 sections, sectionToIdx, sectionIdxsForFunctionCompression,
268269 &duplicateSectionIdxs, maxUN);
0 commit comments