aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/SyntheticSections.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-01-25 23:53:23 -0800
committerFangrui Song <i@maskray.me>2022-01-25 23:53:23 -0800
commit3704abaa166bec865f56f48337a1732eab77dc68 (patch)
tree35079ab2dc4401ec4439fa3c04e211ac3bf12a5f /lld/ELF/SyntheticSections.cpp
parent74acd744d35eebe4a6716026f5f3e9ee9bf15411 (diff)
downloadllvm-3704abaa166bec865f56f48337a1732eab77dc68.zip
llvm-3704abaa166bec865f56f48337a1732eab77dc68.tar.gz
llvm-3704abaa166bec865f56f48337a1732eab77dc68.tar.bz2
[ELF] --gdb-index: replace vector<uint8_t> with unique_ptr<uint8_t[]>. NFC
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
-rw-r--r--lld/ELF/SyntheticSections.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index f442aca..f125e3f 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2806,7 +2806,7 @@ createSymbols(ArrayRef<std::vector<GdbIndexSection::NameAttrEntry>> nameAttrs,
// For each chunk, compute the number of compilation units preceding it.
uint32_t cuIdx = 0;
- std::vector<uint32_t> cuIdxs(chunks.size());
+ std::unique_ptr<uint32_t[]> cuIdxs(new uint32_t[chunks.size()]);
for (uint32_t i = 0, e = chunks.size(); i != e; ++i) {
cuIdxs[i] = cuIdx;
cuIdx += chunks[i].compilationUnits.size();
@@ -2822,11 +2822,13 @@ createSymbols(ArrayRef<std::vector<GdbIndexSection::NameAttrEntry>> nameAttrs,
numShards));
// A sharded map to uniquify symbols by name.
- std::vector<DenseMap<CachedHashStringRef, size_t>> map(numShards);
+ auto map =
+ std::make_unique<DenseMap<CachedHashStringRef, size_t>[]>(numShards);
size_t shift = 32 - countTrailingZeros(numShards);
// Instantiate GdbSymbols while uniqufying them by name.
- std::vector<std::vector<GdbSymbol>> symbols(numShards);
+ auto symbols = std::make_unique<std::vector<GdbSymbol>[]>(numShards);
+
parallelForEachN(0, concurrency, [&](size_t threadId) {
uint32_t i = 0;
for (ArrayRef<NameAttrEntry> entries : nameAttrs) {
@@ -2850,14 +2852,15 @@ createSymbols(ArrayRef<std::vector<GdbIndexSection::NameAttrEntry>> nameAttrs,
});
size_t numSymbols = 0;
- for (ArrayRef<GdbSymbol> v : symbols)
+ for (ArrayRef<GdbSymbol> v : makeArrayRef(symbols.get(), numShards))
numSymbols += v.size();
// The return type is a flattened vector, so we'll copy each vector
// contents to Ret.
std::vector<GdbSymbol> ret;
ret.reserve(numSymbols);
- for (std::vector<GdbSymbol> &vec : symbols)
+ for (std::vector<GdbSymbol> &vec :
+ makeMutableArrayRef(symbols.get(), numShards))
for (GdbSymbol &sym : vec)
ret.push_back(std::move(sym));