[lld] c13258a - [ELF] Replace log with Log(ctx)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 7 09:30:26 PST 2024


Author: Fangrui Song
Date: 2024-11-07T09:30:20-08:00
New Revision: c13258ac495af2cca829752405123b5c9b70fa80

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

LOG: [ELF] Replace log with Log(ctx)

Added: 
    

Modified: 
    lld/ELF/AArch64ErrataFix.cpp
    lld/ELF/ARMErrataFix.cpp
    lld/ELF/Arch/LoongArch.cpp
    lld/ELF/Arch/RISCV.cpp
    lld/ELF/Driver.cpp
    lld/ELF/ICF.cpp
    lld/ELF/InputFiles.cpp
    lld/ELF/LinkerScript.cpp
    lld/ELF/SyntheticSections.cpp
    lld/test/ELF/arm-fix-cortex-a8-blx.s
    lld/test/ELF/arm-fix-cortex-a8-recognize.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/AArch64ErrataFix.cpp b/lld/ELF/AArch64ErrataFix.cpp
index f9e03ce5bbe4db..df4d1aea63f1bc 100644
--- a/lld/ELF/AArch64ErrataFix.cpp
+++ b/lld/ELF/AArch64ErrataFix.cpp
@@ -553,8 +553,8 @@ static void implementPatch(Ctx &ctx, uint64_t adrpAddr, uint64_t patcheeOffset,
       (relIt->type == R_AARCH64_JUMP26 || relIt->expr == R_RELAX_TLS_IE_TO_LE))
     return;
 
-  log("detected cortex-a53-843419 erratum sequence starting at " +
-      utohexstr(adrpAddr) + " in unpatched output.");
+  Log(ctx) << "detected cortex-a53-843419 erratum sequence starting at " <<
+      utohexstr(adrpAddr) << " in unpatched output.";
 
   auto *ps = make<Patch843419Section>(ctx, isec, patcheeOffset);
   patches.push_back(ps);

diff  --git a/lld/ELF/ARMErrataFix.cpp b/lld/ELF/ARMErrataFix.cpp
index 66217303812486..7984e84c88a696 100644
--- a/lld/ELF/ARMErrataFix.cpp
+++ b/lld/ELF/ARMErrataFix.cpp
@@ -420,8 +420,8 @@ void ARMErr657417Patcher::insertPatches(
 static void implementPatch(ScanResult sr, InputSection *isec,
                            std::vector<Patch657417Section *> &patches) {
   Ctx &ctx = isec->getCtx();
-  log("detected cortex-a8-657419 erratum sequence starting at " +
-      utohexstr(isec->getVA(sr.off)) + " in unpatched output.");
+  Log(ctx) << "detected cortex-a8-657419 erratum sequence starting at " <<
+      utohexstr(isec->getVA(sr.off)) << " in unpatched output";
   Patch657417Section *psec;
   // We have two cases to deal with.
   // Case 1. There is a relocation at patcheeOffset to a symbol. The

diff  --git a/lld/ELF/Arch/LoongArch.cpp b/lld/ELF/Arch/LoongArch.cpp
index edde5f65363a3b..a874c7e909b6bd 100644
--- a/lld/ELF/Arch/LoongArch.cpp
+++ b/lld/ELF/Arch/LoongArch.cpp
@@ -839,7 +839,7 @@ bool LoongArch::relaxOnce(int pass) const {
 }
 
 void LoongArch::finalizeRelax(int passes) const {
-  log("relaxation passes: " + Twine(passes));
+  Log(ctx) << "relaxation passes: " << Twine(passes);
   SmallVector<InputSection *, 0> storage;
   for (OutputSection *osec : ctx.outputSections) {
     if (!(osec->flags & SHF_EXECINSTR))

diff  --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 4e5c4ae9c2f14c..72d5db0e611841 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -934,7 +934,7 @@ bool RISCV::relaxOnce(int pass) const {
 
 void RISCV::finalizeRelax(int passes) const {
   llvm::TimeTraceScope timeScope("Finalize RISC-V relaxation");
-  log("relaxation passes: " + Twine(passes));
+  Log(ctx) << "relaxation passes: " << Twine(passes);
   SmallVector<InputSection *, 0> storage;
   for (OutputSection *osec : ctx.outputSections) {
     if (!(osec->flags & SHF_EXECINSTR))

diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index f5125f9ba4b3a3..ed93029721ecc1 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1724,7 +1724,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
     parallel::strategy = hardware_concurrency(threads);
     ctx.arg.thinLTOJobs = v;
   } else if (parallel::strategy.compute_thread_count() > 16) {
-    log("set maximum concurrency to 16, specify --threads= to change");
+    Log(ctx) << "set maximum concurrency to 16, specify --threads= to change";
     parallel::strategy = hardware_concurrency(16);
   }
   if (auto *arg = args.getLastArg(OPT_thinlto_jobs_eq))

diff  --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index 48d287a0980178..f58e072334638d 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -542,7 +542,7 @@ template <class ELFT> void ICF<ELFT>::run() {
     });
   } while (repeat);
 
-  log("ICF needed " + Twine(cnt) + " iterations");
+  Log(ctx) << "ICF needed " << Twine(cnt) << " iterations";
 
   // Merge sections by the equivalence class.
   forEachClassRange(0, sections.size(), [&](size_t begin, size_t end) {

diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 3b63e46edd0984..b28fcfd7900d85 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -247,7 +247,7 @@ std::optional<MemoryBufferRef> elf::readFile(Ctx &ctx, StringRef path) {
 #endif
   }
 
-  log(path);
+  Log(ctx) << path;
   ctx.arg.dependencyFiles.insert(llvm::CachedHashString(path));
 
   auto mbOrErr = MemoryBuffer::getFile(path, /*IsText=*/false,

diff  --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index cd549067084ede..46efb530af6381 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -752,7 +752,7 @@ void LinkerScript::processSectionCommands() {
     if (auto *osd = dyn_cast<OutputDesc>(base)) {
       OutputSection *osec = &osd->osec;
       if (OutputDesc *overwrite = map.lookup(CachedHashStringRef(osec->name))) {
-        log(overwrite->osec.location + " overwrites " + osec->name);
+        Log(ctx) << overwrite->osec.location << " overwrites " << osec->name;
         overwrite->osec.sectionIndex = i++;
         base = overwrite;
       } else if (process(osec)) {

diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index f502c859113d47..ba2dadece74735 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2116,8 +2116,8 @@ template <class ELFT> bool RelrSection<ELFT>::updateAllocSize(Ctx &ctx) {
   // Don't allow the section to shrink; otherwise the size of the section can
   // oscillate infinitely. Trailing 1s do not decode to more relocations.
   if (relrRelocs.size() < oldSize) {
-    log(".relr.dyn needs " + Twine(oldSize - relrRelocs.size()) +
-        " padding word(s)");
+    Log(ctx) << ".relr.dyn needs " << Twine(oldSize - relrRelocs.size()) <<
+        " padding word(s)";
     relrRelocs.resize(oldSize, Elf_Relr(1));
   }
 

diff  --git a/lld/test/ELF/arm-fix-cortex-a8-blx.s b/lld/test/ELF/arm-fix-cortex-a8-blx.s
index 10c9d2aeb46855..736bbe25ed3b76 100644
--- a/lld/test/ELF/arm-fix-cortex-a8-blx.s
+++ b/lld/test/ELF/arm-fix-cortex-a8-blx.s
@@ -7,7 +7,7 @@
 /// will emit these without a relocation, but they could be produced by ELF
 /// processing tools.
 
-// CHECK: ld.lld: detected cortex-a8-657419 erratum sequence starting at 21FFE in unpatched output.
+// CHECK: ld.lld: detected cortex-a8-657419 erratum sequence starting at 21FFE in unpatched output
 
  .syntax unified
  .text

diff  --git a/lld/test/ELF/arm-fix-cortex-a8-recognize.s b/lld/test/ELF/arm-fix-cortex-a8-recognize.s
index ab0ceb8c76cc2c..72e947496deff0 100644
--- a/lld/test/ELF/arm-fix-cortex-a8-recognize.s
+++ b/lld/test/ELF/arm-fix-cortex-a8-recognize.s
@@ -13,13 +13,13 @@
 // RUN: ld.lld --fix-cortex-a8 -verbose -r %t.o -o %t3 2>&1 | FileCheck --check-prefix=CHECK-RELOCATABLE-LLD %s
 // RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d %t3 --start-address=0xffa --stop-address=0x1002 | FileCheck --check-prefix=CHECK-RELOCATABLE %s
 
-// CHECK:      ld.lld: detected cortex-a8-657419 erratum sequence starting at 22FFE in unpatched output.
-// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 23FFE in unpatched output.
-// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 24FFE in unpatched output.
-// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 25FFE in unpatched output.
-// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 26FFE in unpatched output.
-// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 27FFE in unpatched output.
-// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 28FFE in unpatched output.
+// CHECK:      ld.lld: detected cortex-a8-657419 erratum sequence starting at 22FFE in unpatched output
+// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 23FFE in unpatched output
+// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 24FFE in unpatched output
+// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 25FFE in unpatched output
+// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 26FFE in unpatched output
+// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 27FFE in unpatched output
+// CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 28FFE in unpatched output
 
 /// We do not detect errors when doing a relocatable link as we don't know what
 /// the final addresses are.


        


More information about the llvm-commits mailing list