22
22
#include " lld/Common/ErrorHandler.h"
23
23
#include " llvm/ADT/CachedHashString.h"
24
24
#include " llvm/ADT/DenseMap.h"
25
- #include " llvm/ADT/MapVector .h"
25
+ #include " llvm/ADT/DenseSet .h"
26
26
#include " llvm/ADT/SetVector.h"
27
27
#include " llvm/ADT/SmallSet.h"
28
28
#include " llvm/ADT/SmallVector.h"
35
35
#include " llvm/Support/VirtualFileSystem.h"
36
36
#include < memory>
37
37
#include < optional>
38
- #include < set>
39
38
40
39
#define DEBUG_TYPE " bp-section-orderer"
41
40
@@ -61,13 +60,9 @@ template <class D> struct BPOrderer {
61
60
bool forDataCompression,
62
61
bool compressionSortStartupFunctions, bool verbose,
63
62
llvm::ArrayRef<Section *> sections,
64
- const DenseMap<CachedHashStringRef, std::set <unsigned >>
63
+ const DenseMap<CachedHashStringRef, DenseSet <unsigned >>
65
64
&rootSymbolToSectionIdxs)
66
65
-> llvm::DenseMap<const Section *, int>;
67
-
68
- std::optional<StringRef> static getResolvedLinkageName (llvm::StringRef name) {
69
- return {};
70
- }
71
66
};
72
67
} // namespace lld
73
68
@@ -78,7 +73,7 @@ static SmallVector<std::pair<unsigned, UtilityNodes>> getUnsForCompression(
78
73
ArrayRef<const typename D::Section *> sections,
79
74
const DenseMap<const void *, uint64_t > §ionToIdx,
80
75
ArrayRef<unsigned > sectionIdxs,
81
- DenseMap<unsigned , SmallVector<unsigned , 0 >> *duplicateSectionIdxs,
76
+ DenseMap<unsigned , SmallVector<unsigned >> *duplicateSectionIdxs,
82
77
BPFunctionNode::UtilityNodeT &maxUN) {
83
78
TimeTraceScope timeScope (" Build nodes for compression" );
84
79
@@ -93,7 +88,7 @@ static SmallVector<std::pair<unsigned, UtilityNodes>> getUnsForCompression(
93
88
hashes.clear ();
94
89
}
95
90
96
- MapVector <uint64_t , unsigned > hashFrequency;
91
+ DenseMap <uint64_t , unsigned > hashFrequency;
97
92
for (auto &[sectionIdx, hashes] : sectionHashes)
98
93
for (auto hash : hashes)
99
94
++hashFrequency[hash];
@@ -102,11 +97,10 @@ static SmallVector<std::pair<unsigned, UtilityNodes>> getUnsForCompression(
102
97
// Merge sections that are nearly identical
103
98
SmallVector<std::pair<unsigned , SmallVector<uint64_t >>> newSectionHashes;
104
99
DenseMap<uint64_t , unsigned > wholeHashToSectionIdx;
105
- unsigned threshold = sectionHashes.size () > 10000 ? 5 : 0 ;
106
100
for (auto &[sectionIdx, hashes] : sectionHashes) {
107
101
uint64_t wholeHash = 0 ;
108
102
for (auto hash : hashes)
109
- if (hashFrequency[hash] > threshold )
103
+ if (hashFrequency[hash] > 5 )
110
104
wholeHash ^= hash;
111
105
auto [it, wasInserted] =
112
106
wholeHashToSectionIdx.insert (std::make_pair (wholeHash, sectionIdx));
@@ -162,7 +156,7 @@ auto BPOrderer<D>::computeOrder(
162
156
StringRef profilePath, bool forFunctionCompression, bool forDataCompression,
163
157
bool compressionSortStartupFunctions, bool verbose,
164
158
ArrayRef<Section *> sections,
165
- const DenseMap<CachedHashStringRef, std::set <unsigned >>
159
+ const DenseMap<CachedHashStringRef, DenseSet <unsigned >>
166
160
&rootSymbolToSectionIdxs) -> DenseMap<const Section *, int > {
167
161
TimeTraceScope timeScope (" Setup Balanced Partitioning" );
168
162
DenseMap<const void *, uint64_t > sectionToIdx;
@@ -186,7 +180,7 @@ auto BPOrderer<D>::computeOrder(
186
180
}
187
181
auto &traces = reader->getTemporalProfTraces ();
188
182
189
- MapVector <unsigned , BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
183
+ DenseMap <unsigned , BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
190
184
for (size_t traceIdx = 0 ; traceIdx < traces.size (); traceIdx++) {
191
185
uint64_t currentSize = 0 , cutoffSize = 1 ;
192
186
size_t cutoffTimestamp = 1 ;
@@ -263,7 +257,7 @@ auto BPOrderer<D>::computeOrder(
263
257
264
258
// Map a section index (order directly) to a list of duplicate section indices
265
259
// (not ordered directly).
266
- DenseMap<unsigned , SmallVector<unsigned , 0 >> duplicateSectionIdxs;
260
+ DenseMap<unsigned , SmallVector<unsigned >> duplicateSectionIdxs;
267
261
auto unsForFunctionCompression = getUnsForCompression<D>(
268
262
sections, sectionToIdx, sectionIdxsForFunctionCompression,
269
263
&duplicateSectionIdxs, maxUN);
0 commit comments