aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/SyntheticSections.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2021-12-17 19:22:15 -0800
committerFangrui Song <i@maskray.me>2021-12-17 19:22:16 -0800
commit552d84414d2508731ecf2f079fec76b1447020b7 (patch)
treec8da8b29bd9b70ae99a1c0df7c6764fc91e54c02 /lld/ELF/SyntheticSections.cpp
parent212e6c99776f393e0af368ca2086eb8bae2ee1ed (diff)
downloadllvm-552d84414d2508731ecf2f079fec76b1447020b7.zip
llvm-552d84414d2508731ecf2f079fec76b1447020b7.tar.gz
llvm-552d84414d2508731ecf2f079fec76b1447020b7.tar.bz2
[ELF] Use SmallVector for many SyntheticSections. NFC
This decreases struct sizes and usually decreases the lld executable size (39KiB for my x86-64 executable) (unless in some cases smaller SmallVector leads to more inlining, e.g. StringTableBuilder). For --gdb-index, there may be memory usage saving.
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
-rw-r--r--lld/ELF/SyntheticSections.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 95d2cd5..4e4c4c0 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2427,10 +2427,10 @@ static uint32_t hashGnu(StringRef name) {
// Add symbols to this symbol hash table. Note that this function
// destructively sort a given vector -- which is needed because
// GNU-style hash table places some sorting requirements.
-void GnuHashTableSection::addSymbols(std::vector<SymbolTableEntry> &v) {
+void GnuHashTableSection::addSymbols(SmallVectorImpl<SymbolTableEntry> &v) {
// We cannot use 'auto' for Mid because GCC 6.1 cannot deduce
// its type correctly.
- std::vector<SymbolTableEntry>::iterator mid =
+ auto mid =
std::stable_partition(v.begin(), v.end(), [&](const SymbolTableEntry &s) {
return !s.sym->isDefined() || s.sym->partition != partition;
});
@@ -2716,16 +2716,17 @@ void GdbIndexSection::initOutputSize() {
}
}
-static std::vector<GdbIndexSection::CuEntry> readCuList(DWARFContext &dwarf) {
- std::vector<GdbIndexSection::CuEntry> ret;
+static SmallVector<GdbIndexSection::CuEntry, 0>
+readCuList(DWARFContext &dwarf) {
+ SmallVector<GdbIndexSection::CuEntry, 0> ret;
for (std::unique_ptr<DWARFUnit> &cu : dwarf.compile_units())
ret.push_back({cu->getOffset(), cu->getLength() + 4});
return ret;
}
-static std::vector<GdbIndexSection::AddressEntry>
+static SmallVector<GdbIndexSection::AddressEntry, 0>
readAddressAreas(DWARFContext &dwarf, InputSection *sec) {
- std::vector<GdbIndexSection::AddressEntry> ret;
+ SmallVector<GdbIndexSection::AddressEntry, 0> ret;
uint32_t cuIdx = 0;
for (std::unique_ptr<DWARFUnit> &cu : dwarf.compile_units()) {
@@ -2758,7 +2759,7 @@ readAddressAreas(DWARFContext &dwarf, InputSection *sec) {
template <class ELFT>
static std::vector<GdbIndexSection::NameAttrEntry>
readPubNamesAndTypes(const LLDDwarfObj<ELFT> &obj,
- const std::vector<GdbIndexSection::CuEntry> &cus) {
+ const SmallVectorImpl<GdbIndexSection::CuEntry> &cus) {
const LLDDWARFSection &pubNames = obj.getGnuPubnamesSection();
const LLDDWARFSection &pubTypes = obj.getGnuPubtypesSection();