[lld] d9ab62c - [lld-macho] Initialize LTO backend with diagnostic handler
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 4 14:40:21 PDT 2021
Author: Jez Ng
Date: 2021-09-04T17:40:07-04:00
New Revision: d9ab62ca3d292c69d69701541b85efba0f195264
URL: https://github.com/llvm/llvm-project/commit/d9ab62ca3d292c69d69701541b85efba0f195264
DIFF: https://github.com/llvm/llvm-project/commit/d9ab62ca3d292c69d69701541b85efba0f195264.diff
LOG: [lld-macho] Initialize LTO backend with diagnostic handler
Failing to do so results in `std::bad_function_call` being
thrown when a pass tries to emit a diagnostic.
I've copied the relevant test over from LLD-ELF's test suite.
Reviewed By: #lld-macho, thevinster
Differential Revision: https://reviews.llvm.org/D109274
Added:
lld/test/MachO/lto-irmover-warning.ll
Modified:
lld/MachO/LTO.cpp
Removed:
################################################################################
diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index 366193a27eba1..09b05ed0dffee 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -37,6 +37,7 @@ static lto::Config createConfig() {
c.CodeModel = getCodeModelFromCMModel();
c.CPU = getCPUStr();
c.MAttrs = getMAttrs();
+ c.DiagHandler = diagnosticHandler;
c.UseNewPM = config->ltoNewPassManager;
c.PreCodeGenPassesHook = [](legacy::PassManager &pm) {
pm.add(createObjCARCContractPass());
diff --git a/lld/test/MachO/lto-irmover-warning.ll b/lld/test/MachO/lto-irmover-warning.ll
new file mode 100644
index 0000000000000..f781215c83c95
--- /dev/null
+++ b/lld/test/MachO/lto-irmover-warning.ll
@@ -0,0 +1,35 @@
+; REQUIRES: x86
+; RUN: rm -rf %t; split-file %s %t
+; RUN: llvm-as -o %t/first.bc %t/first.ll
+; RUN: llvm-as -o %t/second.bc %t/second.ll
+; RUN: %no_fatal_warnings_lld -dylib %t/first.bc %t/second.bc -o /dev/null 2>&1 | FileCheck %s
+
+;; FIXME: can we replace ld-temp.o with a proper name?
+; CHECK: warning: linking module flags 'foo': IDs have conflicting values ('i32 2' from {{.*}}second.bc with 'i32 1' from ld-temp.o)
+
+;--- first.ll
+target triple = "x86_64-apple-macosx10.15.0"
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+declare void @f()
+
+define void @g() {
+ call void @f()
+ ret void
+}
+
+!0 = !{ i32 2, !"foo", i32 1 }
+
+!llvm.module.flags = !{ !0 }
+
+;--- second.ll
+target triple = "x86_64-apple-macosx10.15.0"
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @f() {
+ ret void
+}
+
+!0 = !{ i32 2, !"foo", i32 2 }
+
+!llvm.module.flags = !{ !0 }
More information about the llvm-commits
mailing list