diff options
author | Vitaly Buka <vitalybuka@google.com> | 2018-02-16 23:34:16 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2018-02-16 23:34:16 +0000 |
commit | c35ff824de59904ff7cc8c93620feacae7947c3b (patch) | |
tree | ff12c23f5aa0a907ff6f9dfbbbbd90fa2d6dfd0a /clang/lib/CodeGen/CodeGenAction.cpp | |
parent | 373e30a2643c6f1ef0981b0f8a1b0d256fbf2ac7 (diff) | |
download | llvm-c35ff824de59904ff7cc8c93620feacae7947c3b.zip llvm-c35ff824de59904ff7cc8c93620feacae7947c3b.tar.gz llvm-c35ff824de59904ff7cc8c93620feacae7947c3b.tar.bz2 |
[ThinLTO] Ignore object files with no ThinLTO modules if -fthinlto-index= is set
Summary:
ThinLTO compilation may decide not to split module and keep at as regular LTO.
In this can this module already processed during indexing and already a part of
merged object file. So here we can just skip it.
Reviewers: pcc, tejohnson
Reviewed By: tejohnson
Subscribers: mehdi_amini, inglorion, eraman, cfe-commits
Differential Revision: https://reviews.llvm.org/D42680
llvm-svn: 325410
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenAction.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 6ca69d6..13fa4a8 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -947,12 +947,21 @@ std::unique_ptr<llvm::Module> CodeGenAction::loadModule(MemoryBufferRef MBRef) { return {}; }; - Expected<llvm::BitcodeModule> BMOrErr = FindThinLTOModule(MBRef); - if (!BMOrErr) - return DiagErrors(BMOrErr.takeError()); - + Expected<std::vector<BitcodeModule>> BMsOrErr = getBitcodeModuleList(MBRef); + if (!BMsOrErr) + return DiagErrors(BMsOrErr.takeError()); + BitcodeModule *Bm = FindThinLTOModule(*BMsOrErr); + // We have nothing to do if the file contains no ThinLTO module. This is + // possible if ThinLTO compilation was not able to split module. Content of + // the file was already processed by indexing and will be passed to the + // linker using merged object file. + if (!Bm) { + auto M = llvm::make_unique<llvm::Module>("empty", *VMContext); + M->setTargetTriple(CI.getTargetOpts().Triple); + return M; + } Expected<std::unique_ptr<llvm::Module>> MOrErr = - BMOrErr->parseModule(*VMContext); + Bm->parseModule(*VMContext); if (!MOrErr) return DiagErrors(MOrErr.takeError()); return std::move(*MOrErr); |