summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO/LTO.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/LTO.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/LTO.cpp')
-rw-r--r--llvm/lib/LTO/LTO.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 30317b9376a..bab8e10a8fa 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -350,19 +350,19 @@ unsigned LTO::getMaxTasks() const {
return RegularLTO.ParallelCodeGenParallelismLevel + ThinLTO.ModuleMap.size();
}
-Error LTO::run(AddStreamFn AddStream) {
+Error LTO::run(AddOutputFn AddOutput) {
// Invoke regular LTO if there was a regular LTO module to start with,
// or if there are any hooks that the linker may have used to add
// its own resolved symbols to the combined module.
if (RegularLTO.HasModule || Conf.PreOptModuleHook ||
Conf.PostInternalizeModuleHook || Conf.PostOptModuleHook ||
Conf.PreCodeGenModuleHook)
- if (auto E = runRegularLTO(AddStream))
+ if (auto E = runRegularLTO(AddOutput))
return E;
- return runThinLTO(AddStream);
+ return runThinLTO(AddOutput);
}
-Error LTO::runRegularLTO(AddStreamFn AddStream) {
+Error LTO::runRegularLTO(AddOutputFn AddOutput) {
if (Conf.PreOptModuleHook &&
!Conf.PreOptModuleHook(0, *RegularLTO.CombinedModule))
return Error();
@@ -388,7 +388,7 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) {
!Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))
return Error();
- return backend(Conf, AddStream, RegularLTO.ParallelCodeGenParallelismLevel,
+ return backend(Conf, AddOutput, RegularLTO.ParallelCodeGenParallelismLevel,
std::move(RegularLTO.CombinedModule));
}
@@ -397,14 +397,14 @@ class lto::ThinBackendProc {
protected:
Config &Conf;
ModuleSummaryIndex &CombinedIndex;
- AddStreamFn AddStream;
+ AddOutputFn AddOutput;
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries;
public:
ThinBackendProc(Config &Conf, ModuleSummaryIndex &CombinedIndex,
- AddStreamFn AddStream,
+ AddOutputFn AddOutput,
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries)
- : Conf(Conf), CombinedIndex(CombinedIndex), AddStream(AddStream),
+ : Conf(Conf), CombinedIndex(CombinedIndex), AddOutput(AddOutput),
ModuleToDefinedGVSummaries(ModuleToDefinedGVSummaries) {}
virtual ~ThinBackendProc() {}
@@ -424,13 +424,13 @@ public:
InProcessThinBackend(Config &Conf, ModuleSummaryIndex &CombinedIndex,
unsigned ThinLTOParallelismLevel,
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
- AddStreamFn AddStream)
- : ThinBackendProc(Conf, CombinedIndex, AddStream,
+ AddOutputFn AddOutput)
+ : ThinBackendProc(Conf, CombinedIndex, AddOutput,
ModuleToDefinedGVSummaries),
BackendThreadPool(ThinLTOParallelismLevel) {}
Error
- runThinLTOBackendThread(AddStreamFn AddStream, unsigned Task,
+ runThinLTOBackendThread(AddOutputFn AddOutput, unsigned Task,
MemoryBufferRef MBRef,
ModuleSummaryIndex &CombinedIndex,
const FunctionImporter::ImportMapTy &ImportList,
@@ -442,7 +442,7 @@ public:
parseBitcodeFile(MBRef, BackendContext);
assert(MOrErr && "Unable to load module in thread?");
- return thinBackend(Conf, Task, AddStream, **MOrErr, CombinedIndex,
+ return thinBackend(Conf, Task, AddOutput, **MOrErr, CombinedIndex,
ImportList, DefinedGlobals, ModuleMap);
}
@@ -456,7 +456,7 @@ public:
GVSummaryMapTy &DefinedGlobals,
MapVector<StringRef, MemoryBufferRef> &ModuleMap) {
Error E =
- runThinLTOBackendThread(AddStream, Task, MBRef, CombinedIndex,
+ runThinLTOBackendThread(AddOutput, Task, MBRef, CombinedIndex,
ImportList, DefinedGlobals, ModuleMap);
if (E) {
std::unique_lock<std::mutex> L(ErrMu);
@@ -483,10 +483,10 @@ public:
ThinBackend lto::createInProcessThinBackend(unsigned ParallelismLevel) {
return [=](Config &Conf, ModuleSummaryIndex &CombinedIndex,
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
- AddStreamFn AddStream) {
+ AddOutputFn AddOutput) {
return llvm::make_unique<InProcessThinBackend>(
Conf, CombinedIndex, ParallelismLevel, ModuleToDefinedGVSummaries,
- AddStream);
+ AddOutput);
};
}
@@ -500,10 +500,10 @@ class WriteIndexesThinBackend : public ThinBackendProc {
public:
WriteIndexesThinBackend(Config &Conf, ModuleSummaryIndex &CombinedIndex,
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
- AddStreamFn AddStream, std::string OldPrefix,
+ AddOutputFn AddOutput, std::string OldPrefix,
std::string NewPrefix, bool ShouldEmitImportsFiles,
std::string LinkedObjectsFileName)
- : ThinBackendProc(Conf, CombinedIndex, AddStream,
+ : ThinBackendProc(Conf, CombinedIndex, AddOutput,
ModuleToDefinedGVSummaries),
OldPrefix(OldPrefix), NewPrefix(NewPrefix),
ShouldEmitImportsFiles(ShouldEmitImportsFiles),
@@ -572,14 +572,14 @@ ThinBackend lto::createWriteIndexesThinBackend(std::string OldPrefix,
std::string LinkedObjectsFile) {
return [=](Config &Conf, ModuleSummaryIndex &CombinedIndex,
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
- AddStreamFn AddStream) {
+ AddOutputFn AddOutput) {
return llvm::make_unique<WriteIndexesThinBackend>(
- Conf, CombinedIndex, ModuleToDefinedGVSummaries, AddStream, OldPrefix,
+ Conf, CombinedIndex, ModuleToDefinedGVSummaries, AddOutput, OldPrefix,
NewPrefix, ShouldEmitImportsFiles, LinkedObjectsFile);
};
}
-Error LTO::runThinLTO(AddStreamFn AddStream) {
+Error LTO::runThinLTO(AddOutputFn AddOutput) {
if (ThinLTO.ModuleMap.empty())
return Error();
@@ -622,7 +622,7 @@ Error LTO::runThinLTO(AddStreamFn AddStream) {
[](StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes) {});
std::unique_ptr<ThinBackendProc> BackendProc = ThinLTO.Backend(
- Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries, AddStream);
+ Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries, AddOutput);
// Partition numbers for ThinLTO jobs start at 1 (see comments for
// GlobalResolution in LTO.h). Task numbers, however, start at
OpenPOWER on IntegriCloud