diff options
| author | Mehdi Amini <mehdi.amini@apple.com> | 2016-08-17 06:23:08 +0000 |
|---|---|---|
| committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-08-17 06:23:08 +0000 |
| commit | 406aa22c6f9663c969e1951fdfac3b745ac63ceb (patch) | |
| tree | 2ec706bc515125d45fcf7da08bcf5ef5ff1968b9 /clang/lib | |
| parent | 2a10c960fa33b7048b48107823f5879cf301dece (diff) | |
| download | bcm5719-llvm-406aa22c6f9663c969e1951fdfac3b745ac63ceb.tar.gz bcm5719-llvm-406aa22c6f9663c969e1951fdfac3b745ac63ceb.zip | |
[ThinLTO] Adapt backend invocation to llvm API changes.
Reviewers: tejohnson
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D23579
llvm-svn: 278906
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 4be716ef123..06f21367ad8 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -724,6 +724,20 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, } } +namespace { +// Wrapper prodiving a stream for the ThinLTO backend. +class ThinLTOOutputWrapper : public lto::NativeObjectOutput { + std::unique_ptr<raw_pwrite_stream> OS; + +public: + ThinLTOOutputWrapper(std::unique_ptr<raw_pwrite_stream> OS) + : OS(std::move(OS)) {} + std::unique_ptr<raw_pwrite_stream> getStream() override { + return std::move(OS); + } +}; +} + static void runThinLTOBackend(const CodeGenOptions &CGOpts, Module *M, std::unique_ptr<raw_pwrite_stream> OS) { // If we are performing a ThinLTO importing compile, load the function index @@ -741,8 +755,6 @@ static void runThinLTOBackend(const CodeGenOptions &CGOpts, Module *M, } std::unique_ptr<ModuleSummaryIndex> CombinedIndex = std::move(*IndexOrErr); - auto AddStream = [&](size_t Task) { return std::move(OS); }; - StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> ModuleToDefinedGVSummaries; CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); @@ -767,10 +779,12 @@ static void runThinLTOBackend(const CodeGenOptions &CGOpts, Module *M, ModuleMap[I.first()] = (*MBOrErr)->getMemBufferRef(); OwnedImports.push_back(std::move(*MBOrErr)); } - + auto AddOutput = [&](size_t Task) { + return llvm::make_unique<ThinLTOOutputWrapper>(std::move(OS)); + }; lto::Config Conf; if (Error E = thinBackend( - Conf, 0, AddStream, *M, *CombinedIndex, ImportList, + Conf, 0, AddOutput, *M, *CombinedIndex, ImportList, ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) { handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) { errs() << "Error running ThinLTO backend: " << EIB.message() << '\n'; |

