mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 00:36:34 +00:00
[lld] BPSectionOrderer: stabilize iteration order
This commit is contained in:
parent
c92f20416e
commit
046dd4b28b
@ -68,7 +68,7 @@ DenseMap<const InputSectionBase *, int> elf::runBalancedPartitioning(
|
||||
bool verbose) {
|
||||
// Collect candidate sections and associated symbols.
|
||||
SmallVector<InputSectionBase *> sections;
|
||||
DenseMap<CachedHashStringRef, DenseSet<unsigned>> rootSymbolToSectionIdxs;
|
||||
DenseMap<CachedHashStringRef, std::set<unsigned>> rootSymbolToSectionIdxs;
|
||||
BPOrdererELF orderer;
|
||||
|
||||
auto addSection = [&](Symbol &sym) {
|
||||
|
@ -110,7 +110,7 @@ DenseMap<const InputSection *, int> lld::macho::runBalancedPartitioning(
|
||||
bool compressionSortStartupFunctions, bool verbose) {
|
||||
// Collect candidate sections and associated symbols.
|
||||
SmallVector<InputSection *> sections;
|
||||
DenseMap<CachedHashStringRef, DenseSet<unsigned>> rootSymbolToSectionIdxs;
|
||||
DenseMap<CachedHashStringRef, std::set<unsigned>> rootSymbolToSectionIdxs;
|
||||
for (const auto *file : inputFiles) {
|
||||
for (auto *sec : file->sections) {
|
||||
for (auto &subsec : sec->subsections) {
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "lld/Common/ErrorHandler.h"
|
||||
#include "llvm/ADT/CachedHashString.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
@ -36,6 +35,7 @@
|
||||
#include "llvm/Support/VirtualFileSystem.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
|
||||
#define DEBUG_TYPE "bp-section-orderer"
|
||||
|
||||
@ -61,7 +61,7 @@ template <class D> struct BPOrderer {
|
||||
bool forDataCompression,
|
||||
bool compressionSortStartupFunctions, bool verbose,
|
||||
llvm::ArrayRef<Section *> sections,
|
||||
const DenseMap<CachedHashStringRef, DenseSet<unsigned>>
|
||||
const DenseMap<CachedHashStringRef, std::set<unsigned>>
|
||||
&rootSymbolToSectionIdxs)
|
||||
-> llvm::DenseMap<const Section *, int>;
|
||||
|
||||
@ -78,7 +78,7 @@ static SmallVector<std::pair<unsigned, UtilityNodes>> getUnsForCompression(
|
||||
ArrayRef<const typename D::Section *> sections,
|
||||
const DenseMap<const void *, uint64_t> §ionToIdx,
|
||||
ArrayRef<unsigned> sectionIdxs,
|
||||
DenseMap<unsigned, SmallVector<unsigned>> *duplicateSectionIdxs,
|
||||
DenseMap<unsigned, SmallVector<unsigned, 0>> *duplicateSectionIdxs,
|
||||
BPFunctionNode::UtilityNodeT &maxUN) {
|
||||
TimeTraceScope timeScope("Build nodes for compression");
|
||||
|
||||
@ -162,7 +162,7 @@ auto BPOrderer<D>::computeOrder(
|
||||
StringRef profilePath, bool forFunctionCompression, bool forDataCompression,
|
||||
bool compressionSortStartupFunctions, bool verbose,
|
||||
ArrayRef<Section *> sections,
|
||||
const DenseMap<CachedHashStringRef, DenseSet<unsigned>>
|
||||
const DenseMap<CachedHashStringRef, std::set<unsigned>>
|
||||
&rootSymbolToSectionIdxs) -> DenseMap<const Section *, int> {
|
||||
TimeTraceScope timeScope("Setup Balanced Partitioning");
|
||||
DenseMap<const void *, uint64_t> sectionToIdx;
|
||||
@ -186,7 +186,7 @@ auto BPOrderer<D>::computeOrder(
|
||||
}
|
||||
auto &traces = reader->getTemporalProfTraces();
|
||||
|
||||
DenseMap<unsigned, BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
|
||||
MapVector<unsigned, BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
|
||||
for (size_t traceIdx = 0; traceIdx < traces.size(); traceIdx++) {
|
||||
uint64_t currentSize = 0, cutoffSize = 1;
|
||||
size_t cutoffTimestamp = 1;
|
||||
@ -263,7 +263,7 @@ auto BPOrderer<D>::computeOrder(
|
||||
|
||||
// Map a section index (order directly) to a list of duplicate section indices
|
||||
// (not ordered directly).
|
||||
DenseMap<unsigned, SmallVector<unsigned>> duplicateSectionIdxs;
|
||||
DenseMap<unsigned, SmallVector<unsigned, 0>> duplicateSectionIdxs;
|
||||
auto unsForFunctionCompression = getUnsForCompression<D>(
|
||||
sections, sectionToIdx, sectionIdxsForFunctionCompression,
|
||||
&duplicateSectionIdxs, maxUN);
|
||||
|
Loading…
x
Reference in New Issue
Block a user