[lld] b8248da - [ELF] Replace remnant config-> with ctx.arg.

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 22 18:03:39 PDT 2024


Author: Fangrui Song
Date: 2024-09-22T18:03:33-07:00
New Revision: b8248dacade77ea5abc49bd8c58d0b1656957492

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

LOG: [ELF] Replace remnant config-> with ctx.arg.

Added: 
    

Modified: 
    lld/ELF/Arch/MipsArchTree.cpp
    lld/ELF/CallGraphSort.cpp
    lld/ELF/Driver.cpp
    lld/ELF/InputSection.cpp
    lld/ELF/LinkerScript.cpp
    lld/ELF/SyntheticSections.cpp
    lld/ELF/Writer.cpp
    lld/ELF/Writer.h

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Arch/MipsArchTree.cpp b/lld/ELF/Arch/MipsArchTree.cpp
index 959bd21a7aa6df..c958ba9032fa35 100644
--- a/lld/ELF/Arch/MipsArchTree.cpp
+++ b/lld/ELF/Arch/MipsArchTree.cpp
@@ -377,7 +377,7 @@ bool elf::isMipsN32Abi(const InputFile *f) {
   case ELF64BEKind:
     return isN32Abi<ELF64BE>(f);
   default:
-    llvm_unreachable("unknown Config->EKind");
+    llvm_unreachable("unknown ctx.arg.ekind");
   }
 }
 

diff  --git a/lld/ELF/CallGraphSort.cpp b/lld/ELF/CallGraphSort.cpp
index 690dc1e80c9a77..e73fe12317bd76 100644
--- a/lld/ELF/CallGraphSort.cpp
+++ b/lld/ELF/CallGraphSort.cpp
@@ -108,7 +108,7 @@ constexpr uint64_t MAX_CLUSTER_SIZE = 1024 * 1024;
 using SectionPair =
     std::pair<const InputSectionBase *, const InputSectionBase *>;
 
-// Take the edge list in Config->CallGraphProfile, resolve symbol names to
+// Take the edge list in ctx.arg.callGraphProfile, resolve symbol names to
 // Symbols, and generate a graph between InputSections with the provided
 // weights.
 CallGraphSort::CallGraphSort() {

diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index c28314b650bef6..346f5be72d8a6f 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -2106,7 +2106,7 @@ static uint64_t getCommonPageSize(Ctx &ctx, opt::InputArgList &args) {
 
 // Parses --image-base option.
 static std::optional<uint64_t> getImageBase(Ctx &ctx, opt::InputArgList &args) {
-  // Because we are using "Config->maxPageSize" here, this function has to be
+  // Because we are using `ctx.arg.maxPageSize` here, this function has to be
   // called after the variable is initialized.
   auto *arg = args.getLastArg(OPT_image_base);
   if (!arg)

diff  --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 12c4a622ebba8e..e9985bbae4959e 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -713,7 +713,7 @@ static int64_t getTlsTpOffset(const Symbol &s) {
     return s.getVA(0) - tls->p_memsz -
            ((-tls->p_vaddr - tls->p_memsz) & (tls->p_align - 1));
   default:
-    llvm_unreachable("unhandled Config->EMachine");
+    llvm_unreachable("unhandled ctx.arg.emachine");
   }
 }
 

diff  --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index b0e1a8de790d3e..55e5f23d041f8f 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -1634,7 +1634,7 @@ SmallVector<PhdrEntry *, 0> LinkerScript::createPhdrs() {
   // Process PHDRS and FILEHDR keywords because they are not
   // real output sections and cannot be added in the following loop.
   for (const PhdrsCommand &cmd : phdrsCommands) {
-    PhdrEntry *phdr = make<PhdrEntry>(cmd.type, cmd.flags.value_or(PF_R));
+    PhdrEntry *phdr = make<PhdrEntry>(ctx, cmd.type, cmd.flags.value_or(PF_R));
 
     if (cmd.hasFilehdr)
       phdr->add(ctx.out.elfHeader);

diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index ecb4a02acc19fe..a736b5d340fcc5 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2057,8 +2057,6 @@ template <class ELFT> bool RelrSection<ELFT>::updateAllocSize() {
   size_t oldSize = relrRelocs.size();
   relrRelocs.clear();
 
-  // Same as Config->Wordsize but faster because this is a compile-time
-  // constant.
   const size_t wordsize = sizeof(typename ELFT::uint);
 
   // Number of bits to use for the relocation offsets bitmap.

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index bf08de0841220e..49a319c643b387 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -2175,8 +2175,8 @@ static uint64_t computeFlags(uint64_t flags) {
 template <class ELFT>
 SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
   SmallVector<PhdrEntry *, 0> ret;
-  auto addHdr = [&](unsigned type, unsigned flags) -> PhdrEntry * {
-    ret.push_back(make<PhdrEntry>(type, flags));
+  auto addHdr = [&, &ctx = ctx](unsigned type, unsigned flags) -> PhdrEntry * {
+    ret.push_back(make<PhdrEntry>(ctx, type, flags));
     return ret.back();
   };
 
@@ -2215,7 +2215,7 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
   // read-only by dynamic linker after processing relocations.
   // Current dynamic loaders only support one PT_GNU_RELRO PHDR, give
   // an error message if more than one PT_GNU_RELRO PHDR is required.
-  PhdrEntry *relRo = make<PhdrEntry>(PT_GNU_RELRO, PF_R);
+  PhdrEntry *relRo = make<PhdrEntry>(ctx, PT_GNU_RELRO, PF_R);
   bool inRelroPhdr = false;
   OutputSection *relroEnd = nullptr;
   for (OutputSection *sec : ctx.outputSections) {
@@ -2292,7 +2292,7 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
   }
 
   // Add a TLS segment if any.
-  PhdrEntry *tlsHdr = make<PhdrEntry>(PT_TLS, PF_R);
+  PhdrEntry *tlsHdr = make<PhdrEntry>(ctx, PT_TLS, PF_R);
   for (OutputSection *sec : ctx.outputSections)
     if (sec->partition == partNo && sec->flags & SHF_TLS)
       tlsHdr->add(sec);
@@ -2377,7 +2377,7 @@ void Writer<ELFT>::addPhdrForSection(Partition &part, unsigned shType,
   if (i == ctx.outputSections.end())
     return;
 
-  PhdrEntry *entry = make<PhdrEntry>(pType, pFlags);
+  PhdrEntry *entry = make<PhdrEntry>(ctx, pType, pFlags);
   entry->add(*i);
   part.phdrs.push_back(entry);
 }

diff  --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h
index c718d27394dc47..7644b620bbffcd 100644
--- a/lld/ELF/Writer.h
+++ b/lld/ELF/Writer.h
@@ -23,8 +23,8 @@ template <class ELFT> void writeResult(Ctx &ctx);
 // Each contains type, access flags and range of output sections that will be
 // placed in it.
 struct PhdrEntry {
-  PhdrEntry(unsigned type, unsigned flags)
-      : p_align(type == llvm::ELF::PT_LOAD ? config->maxPageSize : 0),
+  PhdrEntry(Ctx &ctx, unsigned type, unsigned flags)
+      : p_align(type == llvm::ELF::PT_LOAD ? ctx.arg.maxPageSize : 0),
         p_type(type), p_flags(flags) {}
   void add(OutputSection *sec);
 


        


More information about the llvm-commits mailing list