[lld] lld: Add initial support for GNU LTO format (PR #157175)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 5 14:06:20 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- lld/ELF/Config.h lld/ELF/Driver.cpp lld/ELF/InputFiles.cpp lld/ELF/InputFiles.h lld/ELF/LTO.cpp lld/ELF/LTO.h
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index e0510edd5..fdd6620ae 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1814,9 +1814,10 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
                      << arg->getValue() << "'";
     else if (!ctx.arg.plugin.empty())
 #if LLD_ENABLE_GNU_LTO
-        ctx.arg.pluginOpt.push_back(v.str());
+      ctx.arg.pluginOpt.push_back(v.str());
 #else
-      ErrAlways(ctx) << arg->getSpelling() << " : support for GNU LTO is disabled";
+      ErrAlways(ctx) << arg->getSpelling()
+                     << " : support for GNU LTO is disabled";
 #endif
   }
 
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 551fbb85c..6678be65f 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -324,8 +324,8 @@ private:
 
 class IRFile : public InputFile {
 public:
-  IRFile(Ctx &ctx, MemoryBufferRef m, StringRef archiveName, uint64_t offsetInArchive,
-         bool lazy);
+  IRFile(Ctx &ctx, MemoryBufferRef m, StringRef archiveName,
+         uint64_t offsetInArchive, bool lazy);
   static bool classof(const InputFile *f) { return f->kind() == BitcodeKind; }
   virtual void parse() = 0;
   void parseLazy();
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index dde63aa75..d75827301 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -430,7 +430,7 @@ void BitcodeCompiler::addObject(IRFile &f,
 #if LLD_ENABLE_GNU_LTO
 GccIRCompiler *GccIRCompiler::singleton = nullptr;
 
- GccIRCompiler *GccIRCompiler::getInstance() {
+GccIRCompiler *GccIRCompiler::getInstance() {
   assert(singleton != nullptr);
   return singleton;
 }
@@ -502,21 +502,22 @@ GccIRCompiler::registerClaimFileV2(ld_plugin_claim_file_handler_v2 handler) {
 }
 #endif
 
-enum ld_plugin_status regAllSymbolsRead(ld_plugin_all_symbols_read_handler handler) {
+enum ld_plugin_status
+regAllSymbolsRead(ld_plugin_all_symbols_read_handler handler) {
   GccIRCompiler *c = GccIRCompiler::getInstance();
   return c->registerAllSymbolsRead(handler);
 }
 
-enum ld_plugin_status
-GccIRCompiler::registerAllSymbolsRead(ld_plugin_all_symbols_read_handler handler) {
+enum ld_plugin_status GccIRCompiler::registerAllSymbolsRead(
+    ld_plugin_all_symbols_read_handler handler) {
   allSymbolsReadHandler = handler;
   return LDPS_OK;
 }
 
 static enum ld_plugin_status addSymbols(void *handle, int nsyms,
                                         const struct ld_plugin_symbol *syms) {
-  ELFFileBase *f = (ELFFileBase *) handle;
-  if(f == NULL)
+  ELFFileBase *f = (ELFFileBase *)handle;
+  if (f == NULL)
     return LDPS_ERR;
 
   for (int i = 0; i < nsyms; i++) {
@@ -632,7 +633,7 @@ SmallVector<std::unique_ptr<InputFile>, 0> GccIRCompiler::compile() {
   if (status != LDPS_OK)
     error("The plugin returned an error after all symbols were read.");
 
-  for (auto& m : files) {
+  for (auto &m : files) {
     ret.push_back(createObjFile(ctx, m->getMemBufferRef()));
   }
   return ret;

``````````

</details>


https://github.com/llvm/llvm-project/pull/157175


More information about the llvm-commits mailing list