From 3219c702c08600877d5dba950629ee97809e32e9 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Wed, 17 Aug 2016 06:23:08 +0000 Subject: [PATCH] [ThinLTO] Adapt backend invocation to llvm API changes. Reviewers: tejohnson Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D23579 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@278906 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/BackendUtil.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 4be716ef12..06f21367ad 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/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 OS; + +public: + ThinLTOOutputWrapper(std::unique_ptr OS) + : OS(std::move(OS)) {} + std::unique_ptr getStream() override { + return std::move(OS); + } +}; +} + static void runThinLTOBackend(const CodeGenOptions &CGOpts, Module *M, std::unique_ptr 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 CombinedIndex = std::move(*IndexOrErr); - auto AddStream = [&](size_t Task) { return std::move(OS); }; - StringMap> 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(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'; -- 2.40.0