[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
Wed Aug 10 14:13:00 PDT 2022
arda created this revision.
Herald added subscribers: hiraditya, arichardson, inglorion, emaste.
Herald added a reviewer: MaskRay.
Herald added a project: All.
arda requested review of this revision.
Herald added subscribers: llvm-commits, StephenFan.
Herald added a project: LLVM.
If -ffat-lto-objects enabled and the input files are FatLTO object
files, LTO optimized executable is generated using the LTO bitcode sections
that are embbeded in these FatLTO object files. Otherwise, regular linking is
done using the assembly section in these FatLTO object files.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131618
Files:
lld/ELF/Driver.cpp
lld/ELF/InputFiles.h
llvm/include/llvm/BinaryFormat/Magic.h
llvm/lib/BinaryFormat/Magic.cpp
llvm/lib/Object/Binary.cpp
llvm/lib/Object/ObjectFile.cpp
Index: llvm/lib/Object/ObjectFile.cpp
===================================================================
--- llvm/lib/Object/ObjectFile.cpp
+++ llvm/lib/Object/ObjectFile.cpp
@@ -157,6 +157,7 @@
case file_magic::elf_executable:
case file_magic::elf_shared_object:
case file_magic::elf_core:
+ case file_magic::fatlto_object:
return createELFObjectFile(Object, InitContent);
case file_magic::macho_object:
case file_magic::macho_executable:
Index: llvm/lib/Object/Binary.cpp
===================================================================
--- llvm/lib/Object/Binary.cpp
+++ llvm/lib/Object/Binary.cpp
@@ -55,6 +55,7 @@
case file_magic::elf_executable:
case file_magic::elf_shared_object:
case file_magic::elf_core:
+ case file_magic::fatlto_object:
case file_magic::goff_object:
case file_magic::macho_object:
case file_magic::macho_executable:
Index: llvm/lib/BinaryFormat/Magic.cpp
===================================================================
--- llvm/lib/BinaryFormat/Magic.cpp
+++ llvm/lib/BinaryFormat/Magic.cpp
@@ -79,6 +79,12 @@
return file_magic::offload_binary;
break;
+ case 0xFA:
+ if (startswith(Magic, "\xFAtl\x70")) {
+ return file_magic::fatlto_object;
+ }
+ break;
+
case 0xDE: // 0x0B17C0DE = BC wraper
if (startswith(Magic, "\xDE\xC0\x17\x0B"))
return file_magic::bitcode;
Index: llvm/include/llvm/BinaryFormat/Magic.h
===================================================================
--- llvm/include/llvm/BinaryFormat/Magic.h
+++ llvm/include/llvm/BinaryFormat/Magic.h
@@ -54,6 +54,7 @@
cuda_fatbinary, ///< CUDA Fatbinary object file
offload_binary, ///< LLVM offload object file
dxcontainer_object, ///< DirectX container file
+ fatlto_object, ///< FatLTO object file
};
bool is_object() const { return V != unknown; }
Index: lld/ELF/InputFiles.h
===================================================================
--- lld/ELF/InputFiles.h
+++ lld/ELF/InputFiles.h
@@ -380,6 +380,10 @@
return identify_magic(mb.getBuffer()) == llvm::file_magic::bitcode;
}
+inline bool isFatLTOObject(MemoryBufferRef mb) {
+ return identify_magic(mb.getBuffer()) == llvm::file_magic::fatlto_object;
+}
+
std::string replaceThinLTOSuffix(StringRef path);
} // namespace elf
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -267,6 +267,7 @@
make<SharedFile>(mbref, withLOption ? path::filename(path) : path));
return;
case file_magic::bitcode:
+ case file_magic::fatlto_object:
case file_magic::elf_relocatable:
if (inLib)
files.push_back(createLazyFile(mbref, "", 0));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131618.451627.patch
Type: text/x-patch
Size: 2751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220810/3f1cb8ec/attachment.bin>
More information about the llvm-commits
mailing list