Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp =================================================================== --- cfe/trunk/lib/CodeGen/BackendUtil.cpp +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp @@ -724,6 +724,20 @@ } } +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 @@ } 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 @@ 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';