[PATCH] D79140: [ThinLTO] return error instead of crashing on invalid input

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 8 23:04:16 PST 2023


Amir updated this revision to Diff 487294.
Amir added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79140/new/

https://reviews.llvm.org/D79140

Files:
  lld/test/ELF/stale-profile-error.ll
  llvm/lib/Transforms/IPO/FunctionImport.cpp


Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -1373,8 +1373,9 @@
     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,
+                               "Function Import: link error: %s",
+                               toString(std::move(Err)).c_str());
 
     ImportedCount += GlobalsToImport.size();
     NumImportedModules++;
Index: lld/test/ELF/stale-profile-error.ll
===================================================================
--- /dev/null
+++ lld/test/ELF/stale-profile-error.ll
@@ -0,0 +1,24 @@
+; RUN: split-file %s %t
+; RUN: llvm-as %t/size1.ll -o %t/size1.bc
+; RUN: llvm-as %t/size2.ll -o %t/size2.bc
+
+; RUN: not ld.lld %t/size1.bc %t/size2.bc -S -o - 2>&1 | FileCheck %s
+
+; Test module flags error messages.
+; CHECK: linking module flags 'foo': IDs have conflicting values in '{{.*}}size2.bc' and 'ld-temp.o'
+
+;--- size1.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"
+
+!0 = !{ i32 1, !"foo", i32 37 }
+
+!llvm.module.flags = !{ !0 }
+
+;--- size2.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"
+
+!0 = !{ i32 1, !"foo", i32 38 }
+
+!llvm.module.flags = !{ !0 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79140.487294.patch
Type: text/x-patch
Size: 1758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230109/a62e77c5/attachment.bin>


More information about the llvm-commits mailing list