[llvm] f53de29 - [FunctionImport] Change IRMover report_fatal_error to a proper error
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 23 21:45:20 PST 2023
Author: Fangrui Song
Date: 2023-02-23T21:45:14-08:00
New Revision: f53de29862193b761f3ef8ec0627d1e70d2fe674
URL: https://github.com/llvm/llvm-project/commit/f53de29862193b761f3ef8ec0627d1e70d2fe674
DIFF: https://github.com/llvm/llvm-project/commit/f53de29862193b761f3ef8ec0627d1e70d2fe674.diff
LOG: [FunctionImport] Change IRMover report_fatal_error to a proper error
Conflicting module flags leads to a proper error for regular LTO but a crash
(report_fatal_error) for ThinLTO. Switch to createStringError to fix the crash
and match regular LTO.
Added:
llvm/test/Transforms/FunctionImport/module-flags.ll
Modified:
llvm/lib/Transforms/IPO/FunctionImport.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 7c994657e5c85..222b719c1b89d 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -1373,8 +1373,9 @@ Expected<bool> FunctionImporter::importFunctions(
if (Error Err = Mover.move(std::move(SrcModule),
GlobalsToImport.getArrayRef(), nullptr,
/*IsPerformingImport=*/true))
- report_fatal_error(Twine("Function Import: link error: ") +
- toString(std::move(Err)));
+ return createStringError(errc::invalid_argument,
+ Twine("Function Import: link error: ") +
+ toString(std::move(Err)));
ImportedCount += GlobalsToImport.size();
NumImportedModules++;
diff --git a/llvm/test/Transforms/FunctionImport/module-flags.ll b/llvm/test/Transforms/FunctionImport/module-flags.ll
new file mode 100644
index 0000000000000..662df3065b30f
--- /dev/null
+++ b/llvm/test/Transforms/FunctionImport/module-flags.ll
@@ -0,0 +1,33 @@
+; RUN: rm -rf %t && split-file %s %t && cd %t
+; RUN: opt -module-summary 1.ll -o 1.bc
+; RUN: opt -module-summary 2.ll -o 2.bc
+; RUN: llvm-lto -thinlto -o 3 1.bc 2.bc
+; RUN: opt -S -passes=function-import -summary-file 3.thinlto.bc 1.bc 2>&1 | FileCheck %s
+
+; CHECK: Function Import: link error: linking module flags 'Error': IDs have conflicting values in '2.bc' and '1.bc'
+
+;--- 1.ll
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @main() {
+entry:
+ call void () @foo()
+ ret i32 0
+}
+
+declare void @foo()
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"Error", i32 0}
+
+;--- 2.ll
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @foo() {
+ ret void
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"Error", i32 1}
More information about the llvm-commits
mailing list