Skip to content

AArch64: Fix asserting on unexpected triples #147880

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.

Copy link
Contributor Author

arsenm commented Jul 10, 2025

@arsenm arsenm requested review from lhames, MaskRay and smithp35 July 10, 2025 04:04
@arsenm arsenm marked this pull request as ready for review July 10, 2025 04:04
@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2025

@llvm/pr-subscribers-backend-aarch64

Author: Matt Arsenault (arsenm)

Changes

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

2 Files Affected:

  • (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp (+1-1)
  • (added) llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll (+10)
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
index f918e3cbc7b80..5c8f57664a2cc 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
@@ -356,7 +356,7 @@ static MCAsmInfo *createAArch64MCAsmInfo(const MCRegisterInfo &MRI,
   else if (TheTriple.isOSBinFormatCOFF())
     MAI = new AArch64MCAsmInfoGNUCOFF();
   else
-    llvm_unreachable("Invalid target"); // FIXME: This is not unreachable
+    reportFatalUsageError("unsupported object format");
 
   // Initial state of the frame pointer is SP.
   unsigned Reg = MRI.getDwarfRegNum(AArch64::SP, true);
diff --git a/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll b/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll
new file mode 100644
index 0000000000000..740bde5e43c15
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll
@@ -0,0 +1,10 @@
+; 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
+
+; Make sure there is no crash or assert with unexpected object
+; formats.
+
+; CHECK: LLVM ERROR: unsupported object format
+define void @foo() {
+  ret void
+}

Base automatically changed from users/arsenm/aarch64/base-exception-decision-on-bin-format to main July 10, 2025 04:06
@arsenm arsenm force-pushed the users/arsenm/aarch64/stop-asserting-unexpected-triple branch from 2e6f353 to 5d16133 Compare July 10, 2025 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants