]> granicus.if.org Git - clang/commitdiff
[ThinLTO] Adapt backend invocation to llvm API changes.
authorMehdi Amini <mehdi.amini@apple.com>
Wed, 17 Aug 2016 06:23:08 +0000 (06:23 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Wed, 17 Aug 2016 06:23:08 +0000 (06:23 +0000)
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

index 4be716ef1236c8ddd603371e508ab213a7496d9f..06f21367ad8a7e985a1bb8902e9106a3084be364 100644 (file)
@@ -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';