diff options
author | Vitaly Buka <vitalybuka@google.com> | 2018-01-30 21:19:26 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2018-01-30 21:19:26 +0000 |
commit | 59baf73a4dff3e19b5e0ecdd5b0801691b0db54f (patch) | |
tree | 44ba573d77f01163a9d5ff9a09a7a9229c24b1a5 /llvm/lib/LTO | |
parent | e2fbd7035d14c82fa8451b81dbf72ec84665648f (diff) | |
download | bcm5719-llvm-59baf73a4dff3e19b5e0ecdd5b0801691b0db54f.tar.gz bcm5719-llvm-59baf73a4dff3e19b5e0ecdd5b0801691b0db54f.zip |
[ThinLTO/gold] Write empty imports even for modules with symbols
Summary: ThinLTO may skip object for other reasons, e.g. if there is no summary.
Reviewers: pcc, eugenis
Subscribers: mehdi_amini, inglorion, eraman, llvm-commits
Differential Revision: https://reviews.llvm.org/D42514
llvm-svn: 323818
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 0e705718a64..a5bdeac4d9d 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -1033,16 +1033,18 @@ class WriteIndexesThinBackend : public ThinBackendProc { std::string LinkedObjectsFileName; std::unique_ptr<llvm::raw_fd_ostream> LinkedObjectsFile; + lto::IndexWriteCallback OnWrite; + public: WriteIndexesThinBackend( Config &Conf, ModuleSummaryIndex &CombinedIndex, const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries, std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles, - std::string LinkedObjectsFileName) + std::string LinkedObjectsFileName, lto::IndexWriteCallback OnWrite) : ThinBackendProc(Conf, CombinedIndex, ModuleToDefinedGVSummaries), OldPrefix(OldPrefix), NewPrefix(NewPrefix), ShouldEmitImportsFiles(ShouldEmitImportsFiles), - LinkedObjectsFileName(LinkedObjectsFileName) {} + LinkedObjectsFileName(LinkedObjectsFileName), OnWrite(OnWrite) {} Error start( unsigned Task, BitcodeModule BM, @@ -1075,9 +1077,14 @@ public: return errorCodeToError(EC); WriteIndexToFile(CombinedIndex, OS, &ModuleToSummariesForIndex); - if (ShouldEmitImportsFiles) - return errorCodeToError( - EmitImportsFiles(ModulePath, NewModulePath + ".imports", ImportList)); + if (ShouldEmitImportsFiles) { + EC = EmitImportsFiles(ModulePath, NewModulePath + ".imports", ImportList); + if (EC) + return errorCodeToError(EC); + } + + if (OnWrite) + OnWrite(ModulePath); return Error::success(); } @@ -1088,13 +1095,14 @@ public: ThinBackend lto::createWriteIndexesThinBackend(std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles, - std::string LinkedObjectsFile) { + std::string LinkedObjectsFile, + IndexWriteCallback OnWrite) { return [=](Config &Conf, ModuleSummaryIndex &CombinedIndex, const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries, AddStreamFn AddStream, NativeObjectCache Cache) { return llvm::make_unique<WriteIndexesThinBackend>( Conf, CombinedIndex, ModuleToDefinedGVSummaries, OldPrefix, NewPrefix, - ShouldEmitImportsFiles, LinkedObjectsFile); + ShouldEmitImportsFiles, LinkedObjectsFile, OnWrite); }; } |