summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO/LTOBackend.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-08-17 06:23:09 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-08-17 06:23:09 +0000
commit970800e0c8c7cadcb36be28f6ea300108b9fc551 (patch)
treeb6123cbebf9891a70690b7c374c74066f09dd310 /llvm/lib/LTO/LTOBackend.cpp
parent406aa22c6f9663c969e1951fdfac3b745ac63ceb (diff)
downloadbcm5719-llvm-970800e0c8c7cadcb36be28f6ea300108b9fc551.tar.gz
bcm5719-llvm-970800e0c8c7cadcb36be28f6ea300108b9fc551.zip
[LTO] Introduce an Output class to wrap the output stream creation (NFC)
Summary: While NFC for now, this will allow more flexibility on the client side to hold state necessary to back up the stream. Also when adding caching, this class will grow in complexity. Note I blindly modified the gold-plugin as I can't compile it. Reviewers: tejohnson Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D23542 llvm-svn: 278907
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 8844199e7fc..e80aa7b349a 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -19,6 +19,7 @@
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/LegacyPassManager.h"
+#include "llvm/LTO/LTO.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
@@ -144,12 +145,13 @@ bool opt(Config &C, TargetMachine *TM, unsigned Task, Module &M,
return true;
}
-void codegen(Config &C, TargetMachine *TM, AddStreamFn AddStream, unsigned Task,
+void codegen(Config &C, TargetMachine *TM, AddOutputFn AddOutput, unsigned Task,
Module &M) {
if (C.PreCodeGenModuleHook && !C.PreCodeGenModuleHook(Task, M))
return;
- std::unique_ptr<raw_pwrite_stream> OS = AddStream(Task);
+ auto Output = AddOutput(Task);
+ std::unique_ptr<raw_pwrite_stream> OS = Output->getStream();
legacy::PassManager CodeGenPasses;
if (TM->addPassesToEmitFile(CodeGenPasses, *OS,
TargetMachine::CGFT_ObjectFile))
@@ -157,7 +159,7 @@ void codegen(Config &C, TargetMachine *TM, AddStreamFn AddStream, unsigned Task,
CodeGenPasses.run(M);
}
-void splitCodeGen(Config &C, TargetMachine *TM, AddStreamFn AddStream,
+void splitCodeGen(Config &C, TargetMachine *TM, AddOutputFn AddOutput,
unsigned ParallelCodeGenParallelismLevel,
std::unique_ptr<Module> M) {
ThreadPool CodegenThreadPool(ParallelCodeGenParallelismLevel);
@@ -190,7 +192,7 @@ void splitCodeGen(Config &C, TargetMachine *TM, AddStreamFn AddStream,
std::unique_ptr<TargetMachine> TM =
createTargetMachine(C, MPartInCtx->getTargetTriple(), T);
- codegen(C, TM.get(), AddStream, ThreadId, *MPartInCtx);
+ codegen(C, TM.get(), AddOutput, ThreadId, *MPartInCtx);
},
// Pass BC using std::move to ensure that it get moved rather than
// copied into the thread's context.
@@ -214,7 +216,7 @@ Expected<const Target *> initAndLookupTarget(Config &C, Module &M) {
}
-Error lto::backend(Config &C, AddStreamFn AddStream,
+Error lto::backend(Config &C, AddOutputFn AddOutput,
unsigned ParallelCodeGenParallelismLevel,
std::unique_ptr<Module> M) {
Expected<const Target *> TOrErr = initAndLookupTarget(C, *M);
@@ -228,14 +230,14 @@ Error lto::backend(Config &C, AddStreamFn AddStream,
return Error();
if (ParallelCodeGenParallelismLevel == 1)
- codegen(C, TM.get(), AddStream, 0, *M);
+ codegen(C, TM.get(), AddOutput, 0, *M);
else
- splitCodeGen(C, TM.get(), AddStream, ParallelCodeGenParallelismLevel,
+ splitCodeGen(C, TM.get(), AddOutput, ParallelCodeGenParallelismLevel,
std::move(M));
return Error();
}
-Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream,
+Error lto::thinBackend(Config &Conf, unsigned Task, AddOutputFn AddOutput,
Module &Mod, ModuleSummaryIndex &CombinedIndex,
const FunctionImporter::ImportMapTy &ImportList,
const GVSummaryMapTy &DefinedGlobals,
@@ -281,6 +283,6 @@ Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream,
if (!opt(Conf, TM.get(), Task, Mod, /*IsThinLto=*/true))
return Error();
- codegen(Conf, TM.get(), AddStream, Task, Mod);
+ codegen(Conf, TM.get(), AddOutput, Task, Mod);
return Error();
}
OpenPOWER on IntegriCloud