diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-02-11 12:38:04 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-02-11 12:38:11 +0000 |
| commit | e3b557809604d036af6e00c60f012c2025b59a5e (patch) | |
| tree | 8a11ba2269a3b669601e2fd41145b174008f4da8 /lld/ELF/CallGraphSort.cpp | |
| parent | 08e8dd7b9db7bb4a9de26d44c1cbfd24e869c014 (diff) | |
Diffstat (limited to 'lld/ELF/CallGraphSort.cpp')
| -rw-r--r-- | lld/ELF/CallGraphSort.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lld/ELF/CallGraphSort.cpp b/lld/ELF/CallGraphSort.cpp index 23f1da93c45b..ff72731b1f38 100644 --- a/lld/ELF/CallGraphSort.cpp +++ b/lld/ELF/CallGraphSort.cpp @@ -156,7 +156,7 @@ static bool isNewDensityBad(Cluster &a, Cluster &b) { // Find the leader of V's belonged cluster (represented as an equivalence // class). We apply union-find path-halving technique (simple to implement) in // the meantime as it decreases depths and the time complexity. -static int getLeader(std::vector<int> &leaders, int v) { +static int getLeader(int *leaders, int v) { while (leaders[v] != v) { leaders[v] = leaders[leaders[v]]; v = leaders[v]; @@ -181,9 +181,9 @@ static void mergeClusters(std::vector<Cluster> &cs, Cluster &into, int intoIdx, // then sort the clusters by density. DenseMap<const InputSectionBase *, int> CallGraphSort::run() { std::vector<int> sorted(clusters.size()); - std::vector<int> leaders(clusters.size()); + std::unique_ptr<int[]> leaders(new int[clusters.size()]); - std::iota(leaders.begin(), leaders.end(), 0); + std::iota(leaders.get(), leaders.get() + clusters.size(), 0); std::iota(sorted.begin(), sorted.end(), 0); llvm::stable_sort(sorted, [&](int a, int b) { return clusters[a].getDensity() > clusters[b].getDensity(); @@ -198,7 +198,7 @@ DenseMap<const InputSectionBase *, int> CallGraphSort::run() { if (c.bestPred.from == -1 || c.bestPred.weight * 10 <= c.initialWeight) continue; - int predL = getLeader(leaders, c.bestPred.from); + int predL = getLeader(leaders.get(), c.bestPred.from); if (l == predL) continue; |
