[PATCH] D152973: [gold] Add preliminary FatLTO support to the Gold plugin

Paul Kirth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 14 15:27:54 PDT 2023


paulkirth created this revision.
paulkirth added reviewers: tejohnson, MaskRay, phosek, nikic, aeubanks, alexander-shaposhnikov.
Herald added subscribers: ormris, StephenFan, steven_wu, hiraditya, inglorion.
Herald added a project: All.
paulkirth requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This changes the definition if `isSectionBitcode` to only be valid for the
`.llvm.lto` section, since this API is only called from LTO, and the
`.llvmbc` section was not intended to be used for LTO. This allows the
gold plugin to keep its existing behavior without introducing any
significant changes.

Depends on D146778 <https://reviews.llvm.org/D146778>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152973

Files:
  llvm/lib/Object/ObjectFile.cpp
  llvm/test/LTO/X86/Inputs/bcsection.s
  llvm/tools/gold/gold-plugin.cpp


Index: llvm/tools/gold/gold-plugin.cpp
===================================================================
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -538,14 +538,6 @@
     BufferRef = Buffer->getMemBufferRef();
   }
 
-  // Only use bitcode files for LTO.  InputFile::create() will load bitcode
-  // from the .llvmbc section within a binary object, this bitcode is typically
-  // generated by -fembed-bitcode and is not to be used by LLVMgold.so for LTO.
-  if (identify_magic(BufferRef.getBuffer()) != file_magic::bitcode) {
-    *claimed = 0;
-    return LDPS_OK;
-  }
-
   *claimed = 1;
 
   Expected<std::unique_ptr<InputFile>> ObjOrErr = InputFile::create(BufferRef);
Index: llvm/test/LTO/X86/Inputs/bcsection.s
===================================================================
--- llvm/test/LTO/X86/Inputs/bcsection.s
+++ llvm/test/LTO/X86/Inputs/bcsection.s
@@ -1,2 +1,2 @@
-.section .llvmbc
+.section .llvm.lto
 .incbin "bcsection.bc"
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" || *NameOrErr == ".llvm.lto";
+    return *NameOrErr == ".llvm.lto";
   consumeError(NameOrErr.takeError());
   return false;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152973.531548.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230614/0c37cedf/attachment-0001.bin>


More information about the llvm-commits mailing list