Skip to content

MC: Use reportFatalUsageError for COFF with non-windows #147911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Jul 10, 2025

No description provided.

@arsenm arsenm requested a review from MaskRay July 10, 2025 07:55
@arsenm arsenm marked this pull request as ready for review July 10, 2025 07:55
Copy link
Contributor Author

arsenm commented Jul 10, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@llvmbot llvmbot added backend:AArch64 mc Machine (object) code labels Jul 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2025

@llvm/pr-subscribers-mc

@llvm/pr-subscribers-backend-aarch64

Author: Matt Arsenault (arsenm)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/147911.diff

2 Files Affected:

  • (modified) llvm/lib/MC/MCContext.cpp (+4-3)
  • (added) llvm/test/CodeGen/AArch64/nonwindows-coff-mc-error.ll (+5)
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
+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AArch64 mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants