Skip to content

Commit 046dd4b

Browse files
committed
[lld] BPSectionOrderer: stabilize iteration order
1 parent c92f204 commit 046dd4b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

lld/ELF/BPSectionOrderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ DenseMap<const InputSectionBase *, int> elf::runBalancedPartitioning(
6868
bool verbose) {
6969
// Collect candidate sections and associated symbols.
7070
SmallVector<InputSectionBase *> sections;
71-
DenseMap<CachedHashStringRef, DenseSet<unsigned>> rootSymbolToSectionIdxs;
71+
DenseMap<CachedHashStringRef, std::set<unsigned>> rootSymbolToSectionIdxs;
7272
BPOrdererELF orderer;
7373

7474
auto addSection = [&](Symbol &sym) {

lld/MachO/BPSectionOrderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ DenseMap<const InputSection *, int> lld::macho::runBalancedPartitioning(
110110
bool compressionSortStartupFunctions, bool verbose) {
111111
// Collect candidate sections and associated symbols.
112112
SmallVector<InputSection *> sections;
113-
DenseMap<CachedHashStringRef, DenseSet<unsigned>> rootSymbolToSectionIdxs;
113+
DenseMap<CachedHashStringRef, std::set<unsigned>> rootSymbolToSectionIdxs;
114114
for (const auto *file : inputFiles) {
115115
for (auto *sec : file->sections) {
116116
for (auto &subsec : sec->subsections) {

lld/include/lld/Common/BPSectionOrdererBase.inc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "lld/Common/ErrorHandler.h"
2323
#include "llvm/ADT/CachedHashString.h"
2424
#include "llvm/ADT/DenseMap.h"
25-
#include "llvm/ADT/DenseSet.h"
2625
#include "llvm/ADT/MapVector.h"
2726
#include "llvm/ADT/SetVector.h"
2827
#include "llvm/ADT/SmallSet.h"
@@ -36,6 +35,7 @@
3635
#include "llvm/Support/VirtualFileSystem.h"
3736
#include <memory>
3837
#include <optional>
38+
#include <set>
3939

4040
#define DEBUG_TYPE "bp-section-orderer"
4141

@@ -61,7 +61,7 @@ template <class D> struct BPOrderer {
6161
bool forDataCompression,
6262
bool compressionSortStartupFunctions, bool verbose,
6363
llvm::ArrayRef<Section *> sections,
64-
const DenseMap<CachedHashStringRef, DenseSet<unsigned>>
64+
const DenseMap<CachedHashStringRef, std::set<unsigned>>
6565
&rootSymbolToSectionIdxs)
6666
-> llvm::DenseMap<const Section *, int>;
6767

@@ -78,7 +78,7 @@ static SmallVector<std::pair<unsigned, UtilityNodes>> getUnsForCompression(
7878
ArrayRef<const typename D::Section *> sections,
7979
const DenseMap<const void *, uint64_t> &sectionToIdx,
8080
ArrayRef<unsigned> sectionIdxs,
81-
DenseMap<unsigned, SmallVector<unsigned>> *duplicateSectionIdxs,
81+
DenseMap<unsigned, SmallVector<unsigned, 0>> *duplicateSectionIdxs,
8282
BPFunctionNode::UtilityNodeT &maxUN) {
8383
TimeTraceScope timeScope("Build nodes for compression");
8484

@@ -162,7 +162,7 @@ auto BPOrderer<D>::computeOrder(
162162
StringRef profilePath, bool forFunctionCompression, bool forDataCompression,
163163
bool compressionSortStartupFunctions, bool verbose,
164164
ArrayRef<Section *> sections,
165-
const DenseMap<CachedHashStringRef, DenseSet<unsigned>>
165+
const DenseMap<CachedHashStringRef, std::set<unsigned>>
166166
&rootSymbolToSectionIdxs) -> DenseMap<const Section *, int> {
167167
TimeTraceScope timeScope("Setup Balanced Partitioning");
168168
DenseMap<const void *, uint64_t> sectionToIdx;
@@ -186,7 +186,7 @@ auto BPOrderer<D>::computeOrder(
186186
}
187187
auto &traces = reader->getTemporalProfTraces();
188188

189-
DenseMap<unsigned, BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
189+
MapVector<unsigned, BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
190190
for (size_t traceIdx = 0; traceIdx < traces.size(); traceIdx++) {
191191
uint64_t currentSize = 0, cutoffSize = 1;
192192
size_t cutoffTimestamp = 1;
@@ -263,7 +263,7 @@ auto BPOrderer<D>::computeOrder(
263263

264264
// Map a section index (order directly) to a list of duplicate section indices
265265
// (not ordered directly).
266-
DenseMap<unsigned, SmallVector<unsigned>> duplicateSectionIdxs;
266+
DenseMap<unsigned, SmallVector<unsigned, 0>> duplicateSectionIdxs;
267267
auto unsForFunctionCompression = getUnsForCompression<D>(
268268
sections, sectionToIdx, sectionIdxsForFunctionCompression,
269269
&duplicateSectionIdxs, maxUN);

0 commit comments

Comments
 (0)