[llvm] MC: Use reportFatalUsageError for COFF with non-windows (PR #147911)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 14 23:37:57 PDT 2025
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/147911
>From 91501ec6fd4ec72d8f41b5aadb3ca6db16474687 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 10 Jul 2025 16:53:35 +0900
Subject: [PATCH 1/2] MC: Use reportFatalUsageError for COFF with non-windows
---
llvm/lib/MC/MCContext.cpp | 7 ++++---
llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll | 5 +++++
2 files changed, 9 insertions(+), 3 deletions(-)
create mode 100644 llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index b0d1cb41fac1c..890184db1d1ef 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -87,9 +87,10 @@ MCContext::MCContext(const Triple &TheTriple, const MCAsmInfo *mai,
Env = IsMachO;
break;
case Triple::COFF:
- if (!TheTriple.isOSWindows() && !TheTriple.isUEFI())
- report_fatal_error(
- "Cannot initialize MC for non-Windows COFF object files.");
+ if (!TheTriple.isOSWindows() && !TheTriple.isUEFI()) {
+ reportFatalUsageError(
+ "cannot initialize MC for non-Windows COFF object files");
+ }
Env = IsCOFF;
break;
diff --git a/llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll b/llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll
new file mode 100644
index 0000000000000..3e89cac7570a8
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll
@@ -0,0 +1,5 @@
+; RUN: not llc -mtriple=aarch64-unknown-linux-coff -filetype=null %s 2>&1 | FileCheck %s
+; CHECK: LLVM ERROR: cannot initialize MC for non-Windows COFF object files
+define void @foo() {
+ ret void
+}
>From 5f067357c7477f8c330b02b05c17e93c86ac72ad Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Tue, 15 Jul 2025 15:32:07 +0900
Subject: [PATCH 2/2] Merge unsupported object tests
---
llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll | 5 -----
.../CodeGen/AArch64/unsupported-object-format-err.ll | 10 +++++++---
2 files changed, 7 insertions(+), 8 deletions(-)
delete mode 100644 llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll
diff --git a/llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll b/llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll
deleted file mode 100644
index 3e89cac7570a8..0000000000000
--- a/llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll
+++ /dev/null
@@ -1,5 +0,0 @@
-; RUN: not llc -mtriple=aarch64-unknown-linux-coff -filetype=null %s 2>&1 | FileCheck %s
-; CHECK: LLVM ERROR: cannot initialize MC for non-Windows COFF object files
-define void @foo() {
- ret void
-}
diff --git a/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll b/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll
index 740bde5e43c15..0767425d12737 100644
--- a/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll
+++ b/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll
@@ -1,10 +1,14 @@
-; RUN: not llc -mtriple=aarch64-pc-unknown-xcoff -filetype=null %s 2>&1 | FileCheck %s
-; RUN: not llc -mtriple=aarch64-pc-unknown-goff -filetype=null %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple=aarch64-pc-unknown-xcoff -filetype=null %s 2>&1 | FileCheck -check-prefix=OBJFORMAT %s
+; RUN: not llc -mtriple=aarch64-pc-unknown-goff -filetype=null %s 2>&1 | FileCheck -check-prefix=OBJFORMAT %s
+
+; RUN: not llc -mtriple=aarch64-unknown-linux-coff -filetype=null %s 2>&1 | FileCheck -check-prefix=MCINIT %s
+; CHECK: LLVM ERROR: cannot initialize MC for non-Windows COFF object files
; Make sure there is no crash or assert with unexpected object
; formats.
-; CHECK: LLVM ERROR: unsupported object format
+; OBJFORMAT: LLVM ERROR: unsupported object format
+; MCINIT: LLVM ERROR: cannot initialize MC for non-Windows COFF object files
define void @foo() {
ret void
}
More information about the llvm-commits
mailing list