// This function is where all the optimizations of link-time // optimization happens. When LTO is in use, some input files are // not in native object file format but in the LLVM bitcode format. // This function compiles bitcode files into a few big native files // using LLVM functions and replaces bitcode symbols with the results. // Because all bitcode files that consist of a program are passed // to the compiler at once, it can do whole-program optimization. template <class ELFT> void SymbolTable<ELFT>::addCombinedLTOObject() { if (BitcodeFiles.empty()) return; // Compile bitcode files and replace bitcode symbols. LTO.reset(new BitcodeCompiler); for (BitcodeFile *F : BitcodeFiles) LTO->add<ELFT>(*F); for (InputFile *File : LTO->compile()) { ObjectFile<ELFT> *Obj = cast<ObjectFile<ELFT>>(File); DenseSet<CachedHashStringRef> DummyGroups; Obj->parse(DummyGroups); ObjectFiles.push_back(Obj); } }
// This function is where all the optimizations of link-time // optimization happens. When LTO is in use, some input files are // not in native object file format but in the LLVM bitcode format. // This function compiles bitcode files into a few big native files // using LLVM functions and replaces bitcode symbols with the results. // Because all bitcode files that consist of a program are passed // to the compiler at once, it can do whole-program optimization. template <class ELFT> void SymbolTable<ELFT>::addCombinedLtoObject() { if (BitcodeFiles.empty()) return; // Compile bitcode files. Lto.reset(new BitcodeCompiler); for (const std::unique_ptr<BitcodeFile> &F : BitcodeFiles) Lto->add(*F); std::vector<std::unique_ptr<InputFile>> IFs = Lto->compile(); // Replace bitcode symbols. for (auto &IF : IFs) { ObjectFile<ELFT> *Obj = cast<ObjectFile<ELFT>>(IF.release()); DenseSet<StringRef> DummyGroups; Obj->parse(DummyGroups); ObjectFiles.emplace_back(Obj); } }