r278906 - [ThinLTO] Adapt backend invocation to llvm API changes.
Mehdi Amini via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 16 23:23:08 PDT 2016
Author: mehdi_amini
Date: Wed Aug 17 01:23:08 2016
New Revision: 278906
URL: http://llvm.org/viewvc/llvm-project?rev=278906&view=rev
Log:
[ThinLTO] Adapt backend invocation to llvm API changes.
Reviewers: tejohnson
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D23579
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=278906&r1=278905&r2=278906&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Aug 17 01:23:08 2016
@@ -724,6 +724,20 @@ void EmitAssemblyHelper::EmitAssembly(Ba
}
}
+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 Code
}
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 Code
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';
More information about the cfe-commits
mailing list