2017-02-03 07:58:14 +08:00
|
|
|
//===- LTO.cpp ------------------------------------------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-02-03 07:58:14 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "LTO.h"
|
|
|
|
#include "Config.h"
|
|
|
|
#include "InputFiles.h"
|
|
|
|
#include "Symbols.h"
|
2019-01-31 04:46:18 +08:00
|
|
|
#include "lld/Common/Args.h"
|
[lld] unified COFF and ELF error handling on new Common/ErrorHandler
Summary:
The COFF linker and the ELF linker have long had similar but separate
Error.h and Error.cpp files to implement error handling. This change
introduces new error handling code in Common/ErrorHandler.h, changes the
COFF and ELF linkers to use it, and removes the old, separate
implementations.
Reviewers: ruiu
Reviewed By: ruiu
Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits
Differential Revision: https://reviews.llvm.org/D39259
llvm-svn: 316624
2017-10-26 06:28:38 +08:00
|
|
|
#include "lld/Common/ErrorHandler.h"
|
2018-05-23 04:20:25 +08:00
|
|
|
#include "lld/Common/Strings.h"
|
2017-10-03 05:00:41 +08:00
|
|
|
#include "lld/Common/TargetOptionsCommandFlags.h"
|
2017-02-03 07:58:14 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
|
|
|
#include "llvm/ADT/SmallString.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/ADT/Twine.h"
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
#include "llvm/Bitcode/BitcodeWriter.h"
|
2017-02-03 07:58:14 +08:00
|
|
|
#include "llvm/IR/DiagnosticPrinter.h"
|
2017-09-08 08:50:50 +08:00
|
|
|
#include "llvm/LTO/Caching.h"
|
2017-02-03 07:58:14 +08:00
|
|
|
#include "llvm/LTO/Config.h"
|
|
|
|
#include "llvm/LTO/LTO.h"
|
|
|
|
#include "llvm/Object/SymbolicFile.h"
|
|
|
|
#include "llvm/Support/CodeGen.h"
|
|
|
|
#include "llvm/Support/Error.h"
|
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <system_error>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::object;
|
|
|
|
|
|
|
|
using namespace lld;
|
|
|
|
using namespace lld::coff;
|
|
|
|
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
// Creates an empty file to and returns a raw_fd_ostream to write to it.
|
|
|
|
static std::unique_ptr<raw_fd_ostream> openFile(StringRef file) {
|
|
|
|
std::error_code ec;
|
|
|
|
auto ret =
|
2019-08-15 06:28:17 +08:00
|
|
|
std::make_unique<raw_fd_ostream>(file, ec, sys::fs::OpenFlags::OF_None);
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
if (ec) {
|
|
|
|
error("cannot open " + file + ": " + ec.message());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-07-12 02:48:58 +08:00
|
|
|
static std::string getThinLTOOutputFile(StringRef path) {
|
|
|
|
return lto::getThinLTOOutputFile(path,
|
|
|
|
config->thinLTOPrefixReplace.first,
|
|
|
|
config->thinLTOPrefixReplace.second);
|
|
|
|
}
|
|
|
|
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
static lto::Config createConfig() {
|
2019-07-11 13:40:30 +08:00
|
|
|
lto::Config c;
|
|
|
|
c.Options = initTargetOptionsFromCodeGenFlags();
|
2018-03-15 04:25:41 +08:00
|
|
|
|
|
|
|
// Always emit a section per function/datum with LTO. LLVM LTO should get most
|
|
|
|
// of the benefit of linker GC, but there are still opportunities for ICF.
|
2019-07-11 13:40:30 +08:00
|
|
|
c.Options.FunctionSections = true;
|
|
|
|
c.Options.DataSections = true;
|
2018-03-15 04:25:41 +08:00
|
|
|
|
2017-10-11 08:46:58 +08:00
|
|
|
// Use static reloc model on 32-bit x86 because it usually results in more
|
|
|
|
// compact code, and because there are also known code generation bugs when
|
|
|
|
// using the PIC model (see PR34306).
|
2019-07-11 13:40:30 +08:00
|
|
|
if (config->machine == COFF::IMAGE_FILE_MACHINE_I386)
|
|
|
|
c.RelocModel = Reloc::Static;
|
2017-10-11 08:46:58 +08:00
|
|
|
else
|
2019-07-11 13:40:30 +08:00
|
|
|
c.RelocModel = Reloc::PIC_;
|
|
|
|
c.DisableVerify = true;
|
|
|
|
c.DiagHandler = diagnosticHandler;
|
|
|
|
c.OptLevel = config->ltoo;
|
|
|
|
c.CPU = getCPUStr();
|
|
|
|
c.MAttrs = getMAttrs();
|
|
|
|
c.CGOptLevel = args::getCGOptLevel(config->ltoo);
|
|
|
|
|
|
|
|
if (config->saveTemps)
|
|
|
|
checkError(c.addSaveTemps(std::string(config->outputFile) + ".",
|
2018-05-23 04:20:25 +08:00
|
|
|
/*UseInputModulePath*/ true));
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
BitcodeCompiler::BitcodeCompiler() {
|
|
|
|
// Initialize indexFile.
|
|
|
|
if (!config->thinLTOIndexOnlyArg.empty())
|
|
|
|
indexFile = openFile(config->thinLTOIndexOnlyArg);
|
|
|
|
|
|
|
|
// Initialize ltoObj.
|
2019-07-11 13:40:30 +08:00
|
|
|
lto::ThinBackend backend;
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
if (config->thinLTOIndexOnly) {
|
|
|
|
auto OnIndexWrite = [&](StringRef S) { thinIndices.erase(S); };
|
|
|
|
backend = lto::createWriteIndexesThinBackend(
|
2019-07-12 02:48:58 +08:00
|
|
|
config->thinLTOPrefixReplace.first, config->thinLTOPrefixReplace.second,
|
|
|
|
config->thinLTOEmitImportsFiles, indexFile.get(), OnIndexWrite);
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
} else if (config->thinLTOJobs != 0) {
|
2019-07-11 13:40:30 +08:00
|
|
|
backend = lto::createInProcessThinBackend(config->thinLTOJobs);
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
}
|
2017-02-03 07:58:14 +08:00
|
|
|
|
2019-08-15 06:28:17 +08:00
|
|
|
ltoObj = std::make_unique<lto::LTO>(createConfig(), backend,
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
config->ltoPartitions);
|
|
|
|
}
|
2017-02-03 07:58:14 +08:00
|
|
|
|
|
|
|
BitcodeCompiler::~BitcodeCompiler() = default;
|
|
|
|
|
2019-07-11 13:40:30 +08:00
|
|
|
static void undefine(Symbol *s) { replaceSymbol<Undefined>(s, s->getName()); }
|
2017-02-03 07:58:14 +08:00
|
|
|
|
2019-07-11 13:40:30 +08:00
|
|
|
void BitcodeCompiler::add(BitcodeFile &f) {
|
|
|
|
lto::InputFile &obj = *f.obj;
|
|
|
|
unsigned symNum = 0;
|
|
|
|
std::vector<Symbol *> symBodies = f.getSymbols();
|
|
|
|
std::vector<lto::SymbolResolution> resols(symBodies.size());
|
2017-02-03 07:58:14 +08:00
|
|
|
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
if (config->thinLTOIndexOnly)
|
|
|
|
thinIndices.insert(obj.getName());
|
|
|
|
|
2017-02-03 07:58:14 +08:00
|
|
|
// Provide a resolution to the LTO API for each symbol.
|
2019-07-11 13:40:30 +08:00
|
|
|
for (const lto::InputFile::Symbol &objSym : obj.symbols()) {
|
|
|
|
Symbol *sym = symBodies[symNum];
|
|
|
|
lto::SymbolResolution &r = resols[symNum];
|
|
|
|
++symNum;
|
2017-02-03 07:58:14 +08:00
|
|
|
|
|
|
|
// Ideally we shouldn't check for SF_Undefined but currently IRObjectFile
|
|
|
|
// reports two symbols for module ASM defined. Without this check, lld
|
|
|
|
// flags an undefined in IR with a definition in ASM as prevailing.
|
|
|
|
// Once IRObjectFile is fixed to report only one symbol this hack can
|
|
|
|
// be removed.
|
2019-07-11 13:40:30 +08:00
|
|
|
r.Prevailing = !objSym.isUndefined() && sym->getFile() == &f;
|
|
|
|
r.VisibleToRegularObj = sym->isUsedInRegularObj;
|
|
|
|
if (r.Prevailing)
|
|
|
|
undefine(sym);
|
2017-02-03 07:58:14 +08:00
|
|
|
}
|
2019-07-11 13:40:30 +08:00
|
|
|
checkError(ltoObj->add(std::move(f.obj), resols));
|
2017-02-03 07:58:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Merge all the bitcode files we have seen, codegen the result
|
2017-02-07 04:47:55 +08:00
|
|
|
// and return the resulting objects.
|
|
|
|
std::vector<StringRef> BitcodeCompiler::compile() {
|
2019-07-11 13:40:30 +08:00
|
|
|
unsigned maxTasks = ltoObj->getMaxTasks();
|
|
|
|
buf.resize(maxTasks);
|
|
|
|
files.resize(maxTasks);
|
2017-09-08 08:50:50 +08:00
|
|
|
|
|
|
|
// The /lldltocache option specifies the path to a directory in which to cache
|
|
|
|
// native object files for ThinLTO incremental builds. If a path was
|
|
|
|
// specified, configure LTO to use it as the cache directory.
|
2019-07-11 13:40:30 +08:00
|
|
|
lto::NativeObjectCache cache;
|
|
|
|
if (!config->ltoCache.empty())
|
|
|
|
cache = check(lto::localCache(
|
|
|
|
config->ltoCache, [&](size_t task, std::unique_ptr<MemoryBuffer> mb) {
|
|
|
|
files[task] = std::move(mb);
|
2018-02-21 04:21:59 +08:00
|
|
|
}));
|
2017-09-08 08:50:50 +08:00
|
|
|
|
2019-07-11 13:40:30 +08:00
|
|
|
checkError(ltoObj->run(
|
|
|
|
[&](size_t task) {
|
2019-08-15 06:28:17 +08:00
|
|
|
return std::make_unique<lto::NativeObjectStream>(
|
|
|
|
std::make_unique<raw_svector_ostream>(buf[task]));
|
2017-09-08 08:50:50 +08:00
|
|
|
},
|
2019-07-11 13:40:30 +08:00
|
|
|
cache));
|
2017-09-08 08:50:50 +08:00
|
|
|
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
// Emit empty index files for non-indexed files
|
2019-07-12 02:48:58 +08:00
|
|
|
for (StringRef s : thinIndices) {
|
|
|
|
std::string path = getThinLTOOutputFile(s);
|
|
|
|
openFile(path + ".thinlto.bc");
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
if (config->thinLTOEmitImportsFiles)
|
2019-07-12 02:48:58 +08:00
|
|
|
openFile(path + ".imports");
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ThinLTO with index only option is required to generate only the index
|
|
|
|
// files. After that, we exit from linker and ThinLTO backend runs in a
|
|
|
|
// distributed environment.
|
|
|
|
if (config->thinLTOIndexOnly) {
|
2019-08-22 02:24:59 +08:00
|
|
|
if (!config->ltoObjPath.empty())
|
|
|
|
saveBuffer(buf[0], config->ltoObjPath);
|
[lld-link] implement -thinlto-index-only
Summary:
This implements -thinlto-index-only, -thinlto-index-only:,
and -thinlto-emit-imports-files options in lld-link. They are
analogous to their counterparts in ld.lld: -thinlto-index-only
causes us to perform ThinLTO's thin link and write index files,
but not perform code generation. -thinlto-index-only: does the
same, but also writes a text file listing the native object
files expected to be generated. -thinlto-emit-imports-files
creates a text file next to each index file, listing the files
to import from.
Reviewers: ruiu, tejohnson, pcc, rnk
Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64461
llvm-svn: 365800
2019-07-12 02:03:14 +08:00
|
|
|
if (indexFile)
|
|
|
|
indexFile->close();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2019-07-11 13:40:30 +08:00
|
|
|
if (!config->ltoCache.empty())
|
|
|
|
pruneCache(config->ltoCache, config->ltoCachePolicy);
|
2017-02-03 07:58:14 +08:00
|
|
|
|
2019-07-11 13:40:30 +08:00
|
|
|
std::vector<StringRef> ret;
|
|
|
|
for (unsigned i = 0; i != maxTasks; ++i) {
|
|
|
|
if (buf[i].empty())
|
2017-02-09 02:36:41 +08:00
|
|
|
continue;
|
2019-07-11 13:40:30 +08:00
|
|
|
if (config->saveTemps) {
|
|
|
|
if (i == 0)
|
|
|
|
saveBuffer(buf[i], config->outputFile + ".lto.obj");
|
2017-02-09 02:36:41 +08:00
|
|
|
else
|
2019-07-11 13:40:30 +08:00
|
|
|
saveBuffer(buf[i], config->outputFile + Twine(i) + ".lto.obj");
|
2017-02-09 02:36:41 +08:00
|
|
|
}
|
2019-07-11 13:40:30 +08:00
|
|
|
ret.emplace_back(buf[i].data(), buf[i].size());
|
2017-02-09 02:36:41 +08:00
|
|
|
}
|
2017-09-08 08:50:50 +08:00
|
|
|
|
2019-07-11 13:40:30 +08:00
|
|
|
for (std::unique_ptr<MemoryBuffer> &file : files)
|
|
|
|
if (file)
|
|
|
|
ret.push_back(file->getBuffer());
|
2017-09-08 08:50:50 +08:00
|
|
|
|
2019-07-11 13:40:30 +08:00
|
|
|
return ret;
|
2017-02-03 07:58:14 +08:00
|
|
|
}
|