From 09684b08d3b56b8ab0adb8fe46f709aeba29cee6 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 25 Apr 2020 19:15:08 +0100 Subject: [PATCH] llvm: IPO: handle IRMover error handling, bug #45636 Summary: Missing error mangling is noticed in https://bugs.llvm.org/show_bug.cgi?id=45636 where inconsistent profiling input caused llvm/lld to crash as: ``` Program aborted due to an unhandled Error: linking module flags 'ProfileSummary': IDs have conflicting values in 'Mutex_posix.o' and 'nsBrowserApp.o' ``` The change does not change the fact that LLVM crashes but changes error output to say what was incorrect: ``` LLVM ERROR: Function Import: link error: linking module flags 'ProfileSummary': IDs have conflicting values in 'Mutex_posix.o' and 'nsBrowserApp.o' ``` Actual crash has yet to be fixed. Reviewers: lattner Reviewed By: lattner Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78676 --- llvm/lib/Transforms/IPO/FunctionImport.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 2ebd5cbd124a4..a73ba84696e7b 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -1243,10 +1243,12 @@ Expected FunctionImporter::importFunctions( << " from " << SrcModule->getSourceFileName() << "\n"; } - if (Mover.move(std::move(SrcModule), GlobalsToImport.getArrayRef(), - [](GlobalValue &, IRMover::ValueAdder) {}, - /*IsPerformingImport=*/true)) - report_fatal_error("Function Import: link error"); + if (Error Err = Mover.move( + std::move(SrcModule), GlobalsToImport.getArrayRef(), + [](GlobalValue &, IRMover::ValueAdder) {}, + /*IsPerformingImport=*/true)) + report_fatal_error("Function Import: link error: " + + toString(std::move(Err))); ImportedCount += GlobalsToImport.size(); NumImportedModules++;