[lld] 2991a4e - [ELF] Replace functions bAlloc/saver/uniqueSaver with member access

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 16 22:34:18 PST 2024


Author: Fangrui Song
Date: 2024-11-16T22:34:13-08:00
New Revision: 2991a4e2097ab3f32d37fdceab08c658836e312c

URL: https://github.com/llvm/llvm-project/commit/2991a4e2097ab3f32d37fdceab08c658836e312c
DIFF: https://github.com/llvm/llvm-project/commit/2991a4e2097ab3f32d37fdceab08c658836e312c.diff

LOG: [ELF] Replace functions bAlloc/saver/uniqueSaver with member access

Added: 
    

Modified: 
    lld/ELF/AArch64ErrataFix.cpp
    lld/ELF/ARMErrataFix.cpp
    lld/ELF/Arch/LoongArch.cpp
    lld/ELF/Arch/PPC64.cpp
    lld/ELF/Arch/RISCV.cpp
    lld/ELF/Config.h
    lld/ELF/Driver.cpp
    lld/ELF/DriverUtils.cpp
    lld/ELF/InputFiles.cpp
    lld/ELF/InputSection.cpp
    lld/ELF/LTO.cpp
    lld/ELF/LinkerScript.cpp
    lld/ELF/MarkLive.cpp
    lld/ELF/OutputSections.cpp
    lld/ELF/ScriptParser.cpp
    lld/ELF/SyntheticSections.cpp
    lld/ELF/Thunks.cpp
    lld/ELF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/AArch64ErrataFix.cpp b/lld/ELF/AArch64ErrataFix.cpp
index 038d4e08985d81..7c65b8ae8c6657 100644
--- a/lld/ELF/AArch64ErrataFix.cpp
+++ b/lld/ELF/AArch64ErrataFix.cpp
@@ -398,9 +398,9 @@ Patch843419Section::Patch843419Section(Ctx &ctx, InputSection *p, uint64_t off)
       patchee(p), patcheeOffset(off) {
   this->parent = p->getParent();
   patchSym = addSyntheticLocal(
-      ctx, saver(ctx).save("__CortexA53843419_" + utohexstr(getLDSTAddr())),
+      ctx, ctx.saver.save("__CortexA53843419_" + utohexstr(getLDSTAddr())),
       STT_FUNC, 0, getSize(), *this);
-  addSyntheticLocal(ctx, saver(ctx).save("$x"), STT_NOTYPE, 0, 0, *this);
+  addSyntheticLocal(ctx, ctx.saver.save("$x"), STT_NOTYPE, 0, 0, *this);
 }
 
 uint64_t Patch843419Section::getLDSTAddr() const {

diff  --git a/lld/ELF/ARMErrataFix.cpp b/lld/ELF/ARMErrataFix.cpp
index 15bfbaa6d64a39..4257e491121f21 100644
--- a/lld/ELF/ARMErrataFix.cpp
+++ b/lld/ELF/ARMErrataFix.cpp
@@ -141,9 +141,9 @@ Patch657417Section::Patch657417Section(Ctx &ctx, InputSection *p, uint64_t off,
       patchee(p), patcheeOffset(off), instr(instr), isARM(isARM) {
   parent = p->getParent();
   patchSym = addSyntheticLocal(
-      ctx, saver(ctx).save("__CortexA8657417_" + utohexstr(getBranchAddr())),
+      ctx, ctx.saver.save("__CortexA8657417_" + utohexstr(getBranchAddr())),
       STT_FUNC, isARM ? 0 : 1, getSize(), *this);
-  addSyntheticLocal(ctx, saver(ctx).save(isARM ? "$a" : "$t"), STT_NOTYPE, 0, 0,
+  addSyntheticLocal(ctx, ctx.saver.save(isARM ? "$a" : "$t"), STT_NOTYPE, 0, 0,
                     *this);
 }
 

diff  --git a/lld/ELF/Arch/LoongArch.cpp b/lld/ELF/Arch/LoongArch.cpp
index 7a660587a12bf0..0eb56de9c7f32c 100644
--- a/lld/ELF/Arch/LoongArch.cpp
+++ b/lld/ELF/Arch/LoongArch.cpp
@@ -851,7 +851,7 @@ void LoongArch::finalizeRelax(int passes) const {
       MutableArrayRef<Relocation> rels = sec->relocs();
       ArrayRef<uint8_t> old = sec->content();
       size_t newSize = old.size() - aux.relocDeltas[rels.size() - 1];
-      uint8_t *p = bAlloc(ctx).Allocate<uint8_t>(newSize);
+      uint8_t *p = ctx.bAlloc.Allocate<uint8_t>(newSize);
       uint64_t offset = 0;
       int64_t delta = 0;
       sec->content_ = p;

diff  --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp
index cb0a94e3a1a7d9..4dc9f93f5c6880 100644
--- a/lld/ELF/Arch/PPC64.cpp
+++ b/lld/ELF/Arch/PPC64.cpp
@@ -271,7 +271,7 @@ static void writeSequence(Ctx &ctx, const char *prefix, int from,
   char name[16];
   int first;
   const size_t size = 32 - from + tail.size();
-  MutableArrayRef<uint32_t> buf(bAlloc(ctx).Allocate<uint32_t>(size), size);
+  MutableArrayRef<uint32_t> buf(ctx.bAlloc.Allocate<uint32_t>(size), size);
   uint32_t *ptr = buf.data();
   for (int r = from; r < 32; ++r) {
     format("%s%d", prefix, r).snprint(name, sizeof(name));

diff  --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 1f83ffac9f1c2a..5368ced9a4f538 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -947,7 +947,7 @@ void RISCV::finalizeRelax(int passes) const {
       ArrayRef<uint8_t> old = sec->content();
       size_t newSize = old.size() - aux.relocDeltas[rels.size() - 1];
       size_t writesIdx = 0;
-      uint8_t *p = bAlloc(ctx).Allocate<uint8_t>(newSize);
+      uint8_t *p = ctx.bAlloc.Allocate<uint8_t>(newSize);
       uint64_t offset = 0;
       int64_t delta = 0;
       sec->content_ = p;
@@ -1257,7 +1257,7 @@ mergeAttributesSection(Ctx &ctx,
   if (hasArch && xlen != 0) {
     if (auto result = RISCVISAInfo::createFromExtMap(xlen, exts)) {
       merged.strAttr.try_emplace(RISCVAttrs::ARCH,
-                                 saver(ctx).save((*result)->toString()));
+                                 ctx.saver.save((*result)->toString()));
     } else {
       Err(ctx) << result.takeError();
     }

diff  --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index 431d675b41258c..8da1ead03cd26c 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -686,12 +686,6 @@ static inline ArrayRef<VersionDefinition> namedVersionDefs(Ctx &ctx) {
   return llvm::ArrayRef(ctx.arg.versionDefinitions).slice(2);
 }
 
-inline llvm::BumpPtrAllocator &bAlloc(Ctx &ctx) { return ctx.bAlloc; }
-inline llvm::StringSaver &saver(Ctx &ctx) { return ctx.saver; }
-inline llvm::UniqueStringSaver &uniqueSaver(Ctx &ctx) {
-  return ctx.uniqueSaver;
-}
-
 struct ELFSyncStream : SyncStream {
   Ctx &ctx;
   ELFSyncStream(Ctx &ctx, DiagLevel level)

diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 927fa9da65fdea..6e20d9a8527a44 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -330,7 +330,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
 // Add a given library by searching it from input search paths.
 void LinkerDriver::addLibrary(StringRef name) {
   if (std::optional<std::string> path = searchLibrary(ctx, name))
-    addFile(saver(ctx).save(*path), /*withLOption=*/true);
+    addFile(ctx.saver.save(*path), /*withLOption=*/true);
   else
     ctx.e.error("unable to find library -l" + name, ErrorTag::LibNotFound,
                 {name});
@@ -1619,8 +1619,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
 
   // Parse LTO options.
   if (auto *arg = args.getLastArg(OPT_plugin_opt_mcpu_eq))
-    parseClangOption(ctx,
-                     saver(ctx).save("-mcpu=" + StringRef(arg->getValue())),
+    parseClangOption(ctx, ctx.saver.save("-mcpu=" + StringRef(arg->getValue())),
                      arg->getSpelling());
 
   for (opt::Arg *arg : args.filtered(OPT_plugin_opt_eq_minus))
@@ -2567,7 +2566,7 @@ static std::vector<WrappedSymbol> addWrappedSymbols(Ctx &ctx,
                                                     opt::InputArgList &args) {
   std::vector<WrappedSymbol> v;
   DenseSet<StringRef> seen;
-  auto &ss = saver(ctx);
+  auto &ss = ctx.saver;
   for (auto *arg : args.filtered(OPT_wrap)) {
     StringRef name = arg->getValue();
     if (!seen.insert(name).second)
@@ -2582,7 +2581,7 @@ static std::vector<WrappedSymbol> addWrappedSymbols(Ctx &ctx,
 
     // If __real_ is referenced, pull in the symbol if it is lazy. Do this after
     // processing __wrap_ as that may have referenced __real_.
-    StringRef realName = saver(ctx).save("__real_" + name);
+    StringRef realName = ctx.saver.save("__real_" + name);
     if (Symbol *real = ctx.symtab->find(realName)) {
       ctx.symtab->addUnusedUndefined(name, sym->binding);
       // Update sym's binding, which will replace real's later in

diff  --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 97ede74ef736bd..0278c070b24734 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -95,7 +95,7 @@ static void concatLTOPluginOptions(Ctx &ctx,
   for (size_t i = 0, e = args.size(); i != e; ++i) {
     StringRef s = args[i];
     if ((s == "-plugin-opt" || s == "--plugin-opt") && i + 1 != e) {
-      v.push_back(saver(ctx).save(s + "=" + args[i + 1]).data());
+      v.push_back(ctx.saver.save(s + "=" + args[i + 1]).data());
       ++i;
     } else {
       v.push_back(args[i]);
@@ -118,7 +118,7 @@ opt::InputArgList ELFOptTable::parse(Ctx &ctx, ArrayRef<const char *> argv) {
 
   // Expand response files (arguments in the form of @<filename>)
   // and then parse the argument again.
-  cl::ExpandResponseFiles(saver(ctx), getQuotingStyle(ctx, args), vec);
+  cl::ExpandResponseFiles(ctx.saver, getQuotingStyle(ctx, args), vec);
   concatLTOPluginOptions(ctx, vec);
   args = this->ParseArgs(vec, missingIndex, missingCount);
 

diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 5f0c84850a9c75..224912706f2092 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -222,7 +222,7 @@ std::optional<MemoryBufferRef> elf::readFile(Ctx &ctx, StringRef path) {
   // The --chroot option changes our virtual root directory.
   // This is useful when you are dealing with files created by --reproduce.
   if (!ctx.arg.chroot.empty() && path.starts_with("/"))
-    path = saver(ctx).save(ctx.arg.chroot + path);
+    path = ctx.saver.save(ctx.arg.chroot + path);
 
   bool remapped = false;
   auto it = ctx.arg.remapInputs.find(path);
@@ -427,9 +427,9 @@ static void addDependentLibrary(Ctx &ctx, StringRef specifier,
   if (!ctx.arg.dependentLibraries)
     return;
   if (std::optional<std::string> s = searchLibraryBaseName(ctx, specifier))
-    ctx.driver.addFile(saver(ctx).save(*s), /*withLOption=*/true);
+    ctx.driver.addFile(ctx.saver.save(*s), /*withLOption=*/true);
   else if (std::optional<std::string> s = findFromSearchPaths(ctx, specifier))
-    ctx.driver.addFile(saver(ctx).save(*s), /*withLOption=*/true);
+    ctx.driver.addFile(ctx.saver.save(*s), /*withLOption=*/true);
   else if (fs::exists(specifier))
     ctx.driver.addFile(specifier, /*withLOption=*/false);
   else
@@ -1512,7 +1512,7 @@ template <class ELFT> void SharedFile::parse() {
   }
 
   // DSOs are uniquified not by filename but by soname.
-  StringSaver &ss = saver(ctx);
+  StringSaver &ss = ctx.saver;
   DenseMap<CachedHashStringRef, SharedFile *>::iterator it;
   bool wasInserted;
   std::tie(it, wasInserted) =
@@ -1720,7 +1720,7 @@ BitcodeFile::BitcodeFile(Ctx &ctx, MemoryBufferRef mb, StringRef archiveName,
   // into consideration at LTO time (which very likely causes undefined
   // symbols later in the link stage). So we append file offset to make
   // filename unique.
-  StringSaver &ss = saver(ctx);
+  StringSaver &ss = ctx.saver;
   StringRef name = archiveName.empty()
                        ? ss.save(path)
                        : ss.save(archiveName + "(" + path::filename(path) +
@@ -1761,7 +1761,7 @@ static void createBitcodeSymbol(Ctx &ctx, Symbol *&sym,
     // Update objSym.Name to reference (via StringRef) the string saver's copy;
     // this way LTO can reference the same string saver's copy rather than
     // keeping copies of its own.
-    objSym.Name = uniqueSaver(ctx).save(objSym.getName());
+    objSym.Name = ctx.uniqueSaver.save(objSym.getName());
     sym = ctx.symtab->insert(objSym.getName());
   }
 
@@ -1814,14 +1814,13 @@ void BitcodeFile::parse() {
 void BitcodeFile::parseLazy() {
   numSymbols = obj->symbols().size();
   symbols = std::make_unique<Symbol *[]>(numSymbols);
-  auto &ss = uniqueSaver(ctx);
   for (auto [i, irSym] : llvm::enumerate(obj->symbols())) {
     // Symbols can be duplicated in bitcode files because of '#include' and
     // linkonce_odr. Use uniqueSaver to save symbol names for de-duplication.
     // Update objSym.Name to reference (via StringRef) the string saver's copy;
     // this way LTO can reference the same string saver's copy rather than
     // keeping copies of its own.
-    irSym.Name = ss.save(irSym.getName());
+    irSym.Name = ctx.uniqueSaver.save(irSym.getName());
     if (!irSym.isUndefined()) {
       auto *sym = ctx.symtab->insert(irSym.getName());
       sym->resolve(ctx, LazySymbol{*this});
@@ -1858,7 +1857,7 @@ void BinaryFile::parse() {
     if (!isAlnum(c))
       c = '_';
 
-  llvm::StringSaver &ss = saver(ctx);
+  llvm::StringSaver &ss = ctx.saver;
   ctx.symtab->addAndCheckDuplicate(
       ctx, Defined{ctx, this, ss.save(s + "_start"), STB_GLOBAL, STV_DEFAULT,
                    STT_OBJECT, 0, 0, section});

diff  --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index f297075002cf46..90d3faea907230 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -130,7 +130,7 @@ void InputSectionBase::decompress() const {
   {
     static std::mutex mu;
     std::lock_guard<std::mutex> lock(mu);
-    uncompressedBuf = bAlloc(ctx).Allocate<uint8_t>(size);
+    uncompressedBuf = ctx.bAlloc.Allocate<uint8_t>(size);
   }
 
   invokeELFT(decompressAux, ctx, *this, uncompressedBuf, size);

diff  --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index 7379f97f59ca19..4f57463020b16b 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -397,8 +397,8 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
     StringRef ltoObjName;
     if (bitcodeFilePath == "ld-temp.o") {
       ltoObjName =
-          saver(ctx).save(Twine(ctx.arg.outputFile) + ".lto" +
-                          (i == 0 ? Twine("") : Twine('.') + Twine(i)) + ext);
+          ctx.saver.save(Twine(ctx.arg.outputFile) + ".lto" +
+                         (i == 0 ? Twine("") : Twine('.') + Twine(i)) + ext);
     } else {
       StringRef directory = sys::path::parent_path(bitcodeFilePath);
       // For an archive member, which has an identifier like "d/a.a(coll.o at
@@ -412,7 +412,7 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
       sys::path::append(path, directory,
                         outputFileBaseName + ".lto." + baseName + ext);
       sys::path::remove_dots(path, true);
-      ltoObjName = saver(ctx).save(path.str());
+      ltoObjName = ctx.saver.save(path.str());
     }
     if (savePrelink || ctx.arg.ltoEmitAsm)
       saveBuffer(buf[i].second, ltoObjName);

diff  --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 0298294e615595..d3a9302249dad0 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -59,7 +59,7 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const {
         assert(ctx.arg.relocatable && (rel->flags & SHF_LINK_ORDER));
         return s->name;
       }
-      StringSaver &ss = saver(ctx);
+      StringSaver &ss = ctx.saver;
       if (s->type == SHT_CREL)
         return ss.save(".crel" + out->name);
       if (s->type == SHT_RELA)

diff  --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp
index df81d443accd55..08d9ecedf2cc07 100644
--- a/lld/ELF/MarkLive.cpp
+++ b/lld/ELF/MarkLive.cpp
@@ -301,8 +301,8 @@ template <class ELFT> void MarkLive<ELFT>::run() {
       // As a workaround for glibc libc.a before 2.34
       // (https://sourceware.org/PR27492), retain __libc_atexit and similar
       // sections regardless of zStartStopGC.
-      cNamedSections[saver(ctx).save("__start_" + sec->name)].push_back(sec);
-      cNamedSections[saver(ctx).save("__stop_" + sec->name)].push_back(sec);
+      cNamedSections[ctx.saver.save("__start_" + sec->name)].push_back(sec);
+      cNamedSections[ctx.saver.save("__stop_" + sec->name)].push_back(sec);
     }
   }
 

diff  --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index ccc8bb151b7d4e..094524f9b5379b 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -118,9 +118,9 @@ void OutputSection::commitSection(InputSection *isec) {
       type = SHT_CREL;
       if (type == SHT_REL) {
         if (name.consume_front(".rel"))
-          name = saver(ctx).save(".crel" + name);
+          name = ctx.saver.save(".crel" + name);
       } else if (name.consume_front(".rela")) {
-        name = saver(ctx).save(".crel" + name);
+        name = ctx.saver.save(".crel" + name);
       }
     } else {
       if (typeIsSet || !canMergeToProgbits(ctx, type) ||

diff  --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index f7e3a5e418d5a3..f53515cc3f3c0d 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -317,7 +317,7 @@ void ScriptParser::addFile(StringRef s) {
     SmallString<128> pathData;
     StringRef path = (ctx.arg.sysroot + s).toStringRef(pathData);
     if (sys::fs::exists(path))
-      ctx.driver.addFile(saver(ctx).save(path), /*withLOption=*/false);
+      ctx.driver.addFile(ctx.saver.save(path), /*withLOption=*/false);
     else
       setError("cannot find " + s + " inside " + ctx.arg.sysroot);
     return;
@@ -331,7 +331,7 @@ void ScriptParser::addFile(StringRef s) {
     if (ctx.arg.sysroot.empty())
       ctx.driver.addFile(s.substr(1), /*withLOption=*/false);
     else
-      ctx.driver.addFile(saver(ctx).save(ctx.arg.sysroot + "/" + s.substr(1)),
+      ctx.driver.addFile(ctx.saver.save(ctx.arg.sysroot + "/" + s.substr(1)),
                          /*withLOption=*/false);
   } else if (s.starts_with("-l")) {
     // Case 3: search in the list of library paths.
@@ -354,7 +354,7 @@ void ScriptParser::addFile(StringRef s) {
     } else {
       // Finally, search in the list of library paths.
       if (std::optional<std::string> path = findFromSearchPaths(ctx, s))
-        ctx.driver.addFile(saver(ctx).save(*path), /*withLOption=*/true);
+        ctx.driver.addFile(ctx.saver.save(*path), /*withLOption=*/true);
       else
         setError("unable to find " + s);
     }

diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 0dad0f7e6cb9d6..3b971119e8aa3c 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -77,7 +77,7 @@ static ArrayRef<uint8_t> getVersion(Ctx &ctx) {
   // This is only for testing.
   StringRef s = getenv("LLD_VERSION");
   if (s.empty())
-    s = saver(ctx).save(Twine("Linker: ") + getLLDVersion());
+    s = ctx.saver.save(Twine("Linker: ") + getLLDVersion());
 
   // +1 to include the terminating '\0'.
   return {(const uint8_t *)s.data(), s.size() + 1};
@@ -270,7 +270,7 @@ MipsReginfoSection<ELFT>::create(Ctx &ctx) {
 
 InputSection *elf::createInterpSection(Ctx &ctx) {
   // StringSaver guarantees that the returned string ends with '\0'.
-  StringRef s = saver(ctx).save(ctx.arg.dynamicLinker);
+  StringRef s = ctx.saver.save(ctx.arg.dynamicLinker);
   ArrayRef<uint8_t> contents = {(const uint8_t *)s.data(), s.size() + 1};
 
   return make<InputSection>(ctx.internalFile, SHF_ALLOC, SHT_PROGBITS, 1,

diff  --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp
index 7c5bd0556bc7be..c9625453b2eb12 100644
--- a/lld/ELF/Thunks.cpp
+++ b/lld/ELF/Thunks.cpp
@@ -599,7 +599,7 @@ void AArch64ABSLongThunk::writeLong(uint8_t *buf) {
 }
 
 void AArch64ABSLongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__AArch64AbsLongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__AArch64AbsLongThunk_" + destination.getName()),
             STT_FUNC, 0, isec);
   addSymbol("$x", STT_NOTYPE, 0, isec);
   if (!getMayUseShortThunk())
@@ -631,13 +631,13 @@ void AArch64ADRPThunk::writeLong(uint8_t *buf) {
 }
 
 void AArch64ADRPThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__AArch64ADRPThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__AArch64ADRPThunk_" + destination.getName()),
             STT_FUNC, 0, isec);
   addSymbol("$x", STT_NOTYPE, 0, isec);
 }
 
 void AArch64BTILandingPadThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__AArch64BTIThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__AArch64BTIThunk_" + destination.getName()),
             STT_FUNC, 0, isec);
   addSymbol("$x", STT_NOTYPE, 0, isec);
 }
@@ -776,7 +776,7 @@ void ARMV7ABSLongThunk::writeLong(uint8_t *buf) {
 }
 
 void ARMV7ABSLongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__ARMv7ABSLongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__ARMv7ABSLongThunk_" + destination.getName()),
             STT_FUNC, 0, isec);
   addSymbol("$a", STT_NOTYPE, 0, isec);
 }
@@ -793,7 +793,7 @@ void ThumbV7ABSLongThunk::writeLong(uint8_t *buf) {
 }
 
 void ThumbV7ABSLongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__Thumbv7ABSLongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__Thumbv7ABSLongThunk_" + destination.getName()),
             STT_FUNC, 1, isec);
   addSymbol("$t", STT_NOTYPE, 0, isec);
 }
@@ -813,7 +813,7 @@ void ARMV7PILongThunk::writeLong(uint8_t *buf) {
 }
 
 void ARMV7PILongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__ARMV7PILongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__ARMV7PILongThunk_" + destination.getName()),
             STT_FUNC, 0, isec);
   addSymbol("$a", STT_NOTYPE, 0, isec);
 }
@@ -833,7 +833,7 @@ void ThumbV7PILongThunk::writeLong(uint8_t *buf) {
 }
 
 void ThumbV7PILongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__ThumbV7PILongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__ThumbV7PILongThunk_" + destination.getName()),
             STT_FUNC, 1, isec);
   addSymbol("$t", STT_NOTYPE, 0, isec);
 }
@@ -853,7 +853,7 @@ void ThumbV6MABSLongThunk::writeLong(uint8_t *buf) {
 }
 
 void ThumbV6MABSLongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__Thumbv6MABSLongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__Thumbv6MABSLongThunk_" + destination.getName()),
             STT_FUNC, 1, isec);
   addSymbol("$t", STT_NOTYPE, 0, isec);
   if (!getMayUseShortThunk())
@@ -884,9 +884,8 @@ void ThumbV6MABSXOLongThunk::writeLong(uint8_t *buf) {
 }
 
 void ThumbV6MABSXOLongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(
-      saver(ctx).save("__Thumbv6MABSXOLongThunk_" + destination.getName()),
-      STT_FUNC, 1, isec);
+  addSymbol(ctx.saver.save("__Thumbv6MABSXOLongThunk_" + destination.getName()),
+            STT_FUNC, 1, isec);
   addSymbol("$t", STT_NOTYPE, 0, isec);
 }
 
@@ -910,7 +909,7 @@ void ThumbV6MPILongThunk::writeLong(uint8_t *buf) {
 }
 
 void ThumbV6MPILongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__Thumbv6MPILongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__Thumbv6MPILongThunk_" + destination.getName()),
             STT_FUNC, 1, isec);
   addSymbol("$t", STT_NOTYPE, 0, isec);
   if (!getMayUseShortThunk())
@@ -925,7 +924,7 @@ void ARMV5LongLdrPcThunk::writeLong(uint8_t *buf) {
 }
 
 void ARMV5LongLdrPcThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__ARMv5LongLdrPcThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__ARMv5LongLdrPcThunk_" + destination.getName()),
             STT_FUNC, 0, isec);
   addSymbol("$a", STT_NOTYPE, 0, isec);
   if (!getMayUseShortThunk())
@@ -941,7 +940,7 @@ void ARMV4ABSLongBXThunk::writeLong(uint8_t *buf) {
 }
 
 void ARMV4ABSLongBXThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__ARMv4ABSLongBXThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__ARMv4ABSLongBXThunk_" + destination.getName()),
             STT_FUNC, 0, isec);
   addSymbol("$a", STT_NOTYPE, 0, isec);
   if (!getMayUseShortThunk())
@@ -959,7 +958,7 @@ void ThumbV4ABSLongBXThunk::writeLong(uint8_t *buf) {
 }
 
 void ThumbV4ABSLongBXThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__Thumbv4ABSLongBXThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__Thumbv4ABSLongBXThunk_" + destination.getName()),
             STT_FUNC, 1, isec);
   addSymbol("$t", STT_NOTYPE, 0, isec);
   addSymbol("$a", STT_NOTYPE, 4, isec);
@@ -979,7 +978,7 @@ void ThumbV4ABSLongThunk::writeLong(uint8_t *buf) {
 }
 
 void ThumbV4ABSLongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__Thumbv4ABSLongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__Thumbv4ABSLongThunk_" + destination.getName()),
             STT_FUNC, 1, isec);
   addSymbol("$t", STT_NOTYPE, 0, isec);
   addSymbol("$a", STT_NOTYPE, 4, isec);
@@ -998,7 +997,7 @@ void ARMV4PILongBXThunk::writeLong(uint8_t *buf) {
 }
 
 void ARMV4PILongBXThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__ARMv4PILongBXThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__ARMv4PILongBXThunk_" + destination.getName()),
             STT_FUNC, 0, isec);
   addSymbol("$a", STT_NOTYPE, 0, isec);
   if (!getMayUseShortThunk())
@@ -1015,7 +1014,7 @@ void ARMV4PILongThunk::writeLong(uint8_t *buf) {
 }
 
 void ARMV4PILongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__ARMv4PILongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__ARMv4PILongThunk_" + destination.getName()),
             STT_FUNC, 0, isec);
   addSymbol("$a", STT_NOTYPE, 0, isec);
   if (!getMayUseShortThunk())
@@ -1035,7 +1034,7 @@ void ThumbV4PILongBXThunk::writeLong(uint8_t *buf) {
 }
 
 void ThumbV4PILongBXThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__Thumbv4PILongBXThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__Thumbv4PILongBXThunk_" + destination.getName()),
             STT_FUNC, 1, isec);
   addSymbol("$t", STT_NOTYPE, 0, isec);
   addSymbol("$a", STT_NOTYPE, 4, isec);
@@ -1057,7 +1056,7 @@ void ThumbV4PILongThunk::writeLong(uint8_t *buf) {
 }
 
 void ThumbV4PILongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__Thumbv4PILongThunk_" + destination.getName()),
+  addSymbol(ctx.saver.save("__Thumbv4PILongThunk_" + destination.getName()),
             STT_FUNC, 1, isec);
   addSymbol("$t", STT_NOTYPE, 0, isec);
   addSymbol("$a", STT_NOTYPE, 4, isec);
@@ -1072,7 +1071,7 @@ void AVRThunk::writeTo(uint8_t *buf) {
 }
 
 void AVRThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__AVRThunk_" + destination.getName()), STT_FUNC, 0,
+  addSymbol(ctx.saver.save("__AVRThunk_" + destination.getName()), STT_FUNC, 0,
             isec);
 }
 
@@ -1088,8 +1087,8 @@ void MipsThunk::writeTo(uint8_t *buf) {
 }
 
 void MipsThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__LA25Thunk_" + destination.getName()), STT_FUNC,
-            0, isec);
+  addSymbol(ctx.saver.save("__LA25Thunk_" + destination.getName()), STT_FUNC, 0,
+            isec);
 }
 
 InputSection *MipsThunk::getTargetInputSection() const {
@@ -1112,7 +1111,7 @@ void MicroMipsThunk::writeTo(uint8_t *buf) {
 
 void MicroMipsThunk::addSymbols(ThunkSection &isec) {
   Defined *d =
-      addSymbol(saver(ctx).save("__microLA25Thunk_" + destination.getName()),
+      addSymbol(ctx.saver.save("__microLA25Thunk_" + destination.getName()),
                 STT_FUNC, 0, isec);
   d->stOther |= STO_MIPS_MICROMIPS;
 }
@@ -1137,7 +1136,7 @@ void MicroMipsR6Thunk::writeTo(uint8_t *buf) {
 
 void MicroMipsR6Thunk::addSymbols(ThunkSection &isec) {
   Defined *d =
-      addSymbol(saver(ctx).save("__microLA25Thunk_" + destination.getName()),
+      addSymbol(ctx.saver.save("__microLA25Thunk_" + destination.getName()),
                 STT_FUNC, 0, isec);
   d->stOther |= STO_MIPS_MICROMIPS;
 }
@@ -1198,7 +1197,7 @@ void PPC32PltCallStub::addSymbols(ThunkSection &isec) {
   else
     os << ".plt_pic32.";
   os << destination.getName();
-  addSymbol(saver(ctx).save(buf), STT_FUNC, 0, isec);
+  addSymbol(ctx.saver.save(buf), STT_FUNC, 0, isec);
 }
 
 bool PPC32PltCallStub::isCompatibleWith(const InputSection &isec,
@@ -1207,8 +1206,8 @@ bool PPC32PltCallStub::isCompatibleWith(const InputSection &isec,
 }
 
 void PPC32LongThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__LongThunk_" + destination.getName()), STT_FUNC,
-            0, isec);
+  addSymbol(ctx.saver.save("__LongThunk_" + destination.getName()), STT_FUNC, 0,
+            isec);
 }
 
 void PPC32LongThunk::writeTo(uint8_t *buf) {
@@ -1251,7 +1250,7 @@ void PPC64PltCallStub::writeTo(uint8_t *buf) {
 }
 
 void PPC64PltCallStub::addSymbols(ThunkSection &isec) {
-  Defined *s = addSymbol(saver(ctx).save("__plt_" + destination.getName()),
+  Defined *s = addSymbol(ctx.saver.save("__plt_" + destination.getName()),
                          STT_FUNC, 0, isec);
   s->setNeedsTocRestore(true);
   s->file = destination.file;
@@ -1295,7 +1294,7 @@ void PPC64R2SaveStub::writeTo(uint8_t *buf) {
 }
 
 void PPC64R2SaveStub::addSymbols(ThunkSection &isec) {
-  Defined *s = addSymbol(saver(ctx).save("__toc_save_" + destination.getName()),
+  Defined *s = addSymbol(ctx.saver.save("__toc_save_" + destination.getName()),
                          STT_FUNC, 0, isec);
   s->setNeedsTocRestore(true);
 }
@@ -1339,8 +1338,8 @@ void PPC64R12SetupStub::writeTo(uint8_t *buf) {
 }
 
 void PPC64R12SetupStub::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save((gotPlt ? "__plt_pcrel_" : "__gep_setup_") +
-                            destination.getName()),
+  addSymbol(ctx.saver.save((gotPlt ? "__plt_pcrel_" : "__gep_setup_") +
+                           destination.getName()),
             STT_FUNC, 0, isec);
 }
 
@@ -1357,7 +1356,7 @@ void PPC64LongBranchThunk::writeTo(uint8_t *buf) {
 }
 
 void PPC64LongBranchThunk::addSymbols(ThunkSection &isec) {
-  addSymbol(saver(ctx).save("__long_branch_" + destination.getName()), STT_FUNC,
+  addSymbol(ctx.saver.save("__long_branch_" + destination.getName()), STT_FUNC,
             0, isec);
 }
 

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 0ec0da2a4af2c8..69a22229792f5f 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -2153,7 +2153,7 @@ void Writer<ELFT>::addStartStopSymbols(OutputSection &osec) {
   StringRef s = osec.name;
   if (!isValidCIdentifier(s))
     return;
-  StringSaver &ss = saver(ctx);
+  StringSaver &ss = ctx.saver;
   Defined *startSym = addOptionalRegular(ctx, ss.save("__start_" + s), &osec, 0,
                                          ctx.arg.zStartStopVisibility);
   Defined *stopSym = addOptionalRegular(ctx, ss.save("__stop_" + s), &osec, -1,


        


More information about the llvm-commits mailing list