[PATCH] D131618: [WIP][Do NOT review] LLD related changes for -ffat-lto-objects support

Arda Unal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 14:23:11 PDT 2022


arda updated this revision to Diff 451985.
arda added a comment.

Add the -fat-lto-objects flag as a prerequisite to checks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131618/new/

https://reviews.llvm.org/D131618

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/InputFiles.cpp
  lld/ELF/Options.td
  llvm/lib/Object/ObjectFile.cpp


Index: llvm/lib/Object/ObjectFile.cpp
===================================================================
--- llvm/lib/Object/ObjectFile.cpp
+++ llvm/lib/Object/ObjectFile.cpp
@@ -79,7 +79,7 @@
 bool ObjectFile::isSectionBitcode(DataRefImpl Sec) const {
   Expected<StringRef> NameOrErr = getSectionName(Sec);
   if (NameOrErr)
-    return *NameOrErr == ".llvmbc";
+    return *NameOrErr == ".llvmbc" || *NameOrErr == ".fatlto";
   consumeError(NameOrErr.takeError());
   return false;
 }
Index: lld/ELF/Options.td
===================================================================
--- lld/ELF/Options.td
+++ lld/ELF/Options.td
@@ -608,6 +608,10 @@
 def thinlto_single_module_eq: JJ<"thinlto-single-module=">,
   HelpText<"Specific a single module to compile in ThinLTO mode, for debugging only">;
 
+defm fatlto_objects: B<"fat-lto-objects",
+    "Use the embedded bitcode in the .fatlto section of the object file",
+    "Use the assembly in the object file (default)">;
+
 def: J<"plugin-opt=O">, Alias<lto_O>, HelpText<"Alias for --lto-O">;
 def: F<"plugin-opt=debug-pass-manager">,
   Alias<lto_debug_pass_manager>, HelpText<"Alias for --lto-debug-pass-manager">;
Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ lld/ELF/InputFiles.cpp
@@ -1715,6 +1715,13 @@
   if (isBitcode(mb))
     return make<BitcodeFile>(mb, archiveName, offsetInArchive, /*lazy=*/false);
 
+  // If it is a fatLTO object file
+  if (config->fatLTOObjects) {
+    Expected<MemoryBufferRef> fatLTOData = IRObjectFile::findBitcodeInMemBuffer(mb);
+    if (!errorToBool(fatLTOData.takeError()))
+      return make<BitcodeFile>(*fatLTOData, archiveName, offsetInArchive, /*lazy=*/false);
+  }
+
   switch (getELFKind(mb, archiveName)) {
   case ELF32LEKind:
     return make<ObjFile<ELF32LE>>(mb, archiveName);
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1023,6 +1023,11 @@
       args.hasFlag(OPT_allow_multiple_definition,
                    OPT_no_allow_multiple_definition, false) ||
       hasZOption(args, "muldefs");
+
+  config->fatLTOObjects =
+      args.hasFlag(OPT_fatlto_objects,
+                   OPT_no_fatlto_objects, false);
+
   config->androidMemtagHeap =
       args.hasFlag(OPT_android_memtag_heap, OPT_no_android_memtag_heap, false);
   config->androidMemtagStack = args.hasFlag(OPT_android_memtag_stack,
Index: lld/ELF/Config.h
===================================================================
--- lld/ELF/Config.h
+++ lld/ELF/Config.h
@@ -155,6 +155,7 @@
                   uint64_t>
       callGraphProfile;
   bool allowMultipleDefinition;
+  bool fatLTOObjects;
   bool androidPackDynRelocs = false;
   bool armHasBlx = false;
   bool armHasMovtMovw = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131618.451985.patch
Type: text/x-patch
Size: 2846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220811/5c9084fa/attachment.bin>


More information about the llvm-commits mailing list