diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-05-27 05:21:35 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-05-27 05:21:35 +0000 |
commit | b7bfc99302d1d7615c5441861547f0b2a29e6935 (patch) | |
tree | 47ed8277aa54ef8c0dcf57d423ac85a104fd4a11 /tools/gold | |
parent | 9cc0faee6543b49204691df425f01bcd2c9f48ad (diff) |
Linker: teach the IR mover to return llvm::Error.
This will be needed in order to consistently return an Error
to clients of the API being developed in D20268.
Differential Revision: http://reviews.llvm.org/D20550
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/gold')
-rw-r--r-- | tools/gold/gold-plugin.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 7fa1730453af..87b07181dac1 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -1131,8 +1131,8 @@ void CodeGen::runAll() { } /// Links the module in \p View from file \p F into the combined module -/// saved in the IRMover \p L. Returns true on error, false on success. -static bool linkInModule(LLVMContext &Context, IRMover &L, claimed_file &F, +/// saved in the IRMover \p L. +static void linkInModule(LLVMContext &Context, IRMover &L, claimed_file &F, const void *View, StringRef Name, raw_fd_ostream *ApiFile, StringSet<> &Internalize, StringSet<> &Maybe) { @@ -1141,15 +1141,20 @@ static bool linkInModule(LLVMContext &Context, IRMover &L, claimed_file &F, std::unique_ptr<Module> M = getModuleForFile( Context, F, View, Name, ApiFile, Internalize, Maybe, Keep, Realign); if (!M.get()) - return false; + return; if (!options::triple.empty()) M->setTargetTriple(options::triple.c_str()); else if (M->getTargetTriple().empty()) { M->setTargetTriple(DefaultTriple); } - if (L.move(std::move(M), Keep, [](GlobalValue &, IRMover::ValueAdder) {})) - return true; + if (Error E = L.move(std::move(M), Keep, + [](GlobalValue &, IRMover::ValueAdder) {})) { + handleAllErrors(std::move(E), [&](const llvm::ErrorInfoBase &EIB) { + message(LDPL_FATAL, "Failed to link module %s: %s", Name.str().c_str(), + EIB.message().c_str()); + }); + } for (const auto &I : Realign) { GlobalValue *Dst = L.getModule().getNamedValue(I.first()); @@ -1157,8 +1162,6 @@ static bool linkInModule(LLVMContext &Context, IRMover &L, claimed_file &F, continue; cast<GlobalVariable>(Dst)->setAlignment(I.second); } - - return false; } /// Perform the ThinLTO backend on a single module, invoking the LTO and codegen @@ -1179,8 +1182,7 @@ static void thinLTOBackendTask(claimed_file &F, const void *View, IRMover L(*NewModule.get()); StringSet<> Dummy; - if (linkInModule(Context, L, F, View, Name, ApiFile, Dummy, Dummy)) - message(LDPL_FATAL, "Failed to rename module for ThinLTO"); + linkInModule(Context, L, F, View, Name, ApiFile, Dummy, Dummy); if (renameModuleForThinLTO(*NewModule, CombinedIndex)) message(LDPL_FATAL, "Failed to rename module for ThinLTO"); @@ -1420,8 +1422,7 @@ static ld_plugin_status allSymbolsReadHook(raw_fd_ostream *ApiFile) { const void *View = getSymbolsAndView(F); if (!View) continue; - if (linkInModule(Context, L, F, View, F.name, ApiFile, Internalize, Maybe)) - message(LDPL_FATAL, "Failed to link module"); + linkInModule(Context, L, F, View, F.name, ApiFile, Internalize, Maybe); } for (const auto &Name : Internalize) { |