FatLTO objects are a special type of fat object file that contain LTO compatible IR in addition to generated object code, instead of containing object code for multiple target architectures. This allows users to defer the choice of whether to use LTO or not to link-time, and has been a feature available in other compilers, like GCC, for some time.
Under FatLTO the compiler can emit standard object files which contain both the
machine code in the
.text section and LLVM bitcode in the
Within LLVM, FatLTO is supported by choosing the
This pipeline will:
Clone the IR module.
Run the pre-link (Thin)LTO pipeline using the cloned module.
Embed the pre-link bitcode in a special
Optimize the unmodified copy of the module using the normal compilation pipeline.
Emit the object file, including the new
.llvm.lto section is created by running the
EmbedBitcodePass at the start of the
pass is responsible for cloning and optimizing the module with the appropriate
LTO pipeline and emitting the
.llvm.lto section. Afterwards, the
PerModuleDefaultPipeline runs normally and the compiler can emit the fat
The current implementation only supports ELF files. At time of writing, it is
unclear if it will be useful to support other object file formats like