[llvm] [X86] Emit user-friendly error for x86_fp80 with x87 disabled on x86_64 (PR #183932)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 2 19:46:02 PST 2026


================
@@ -1689,6 +1689,21 @@ SDValue X86TargetLowering::LowerFormalArguments(
   bool Is64Bit = Subtarget.is64Bit();
   bool IsWin64 = Subtarget.isCallingConvWin64(CallConv);
 
+  // On x86_64 with x87 disabled, x86_fp80 cannot be handled: the type would
+  // need to be returned/passed in x87 registers (FP0/FP1) which are
+  // unavailable. Emit a clear diagnostic instead of crashing later with
+  // "Cannot select: build_pair".
+  if (Is64Bit && !Subtarget.hasX87()) {
+    if (F.getReturnType()->isX86_FP80Ty())
+      report_fatal_error(
----------------
bala-bhargav wrote:

Thanks for pointing that out, @phoebewang! You're right that Clang catches this at the frontend level with -mno-x87.
However, the original issue (#182450) is specifically about llc taking LLVM IR directly — where there's no frontend to validate the type/attribute combination. The current crash produces LLVM ERROR: Cannot select: build_pair and asks users to file a bug report, which is misleading since it's not actually an LLVM bug.
Using reportFatalUsageError here gives a clean exit with a clear message, without a crash trace or bug-filingprompt. This is consistent with how other unsupported configurations are handled in the X86 backend (e.g., in X86Subtarget.cpp
 for 64-bit code on 32-bit subtargets).

https://github.com/llvm/llvm-project/pull/183932


More information about the llvm-commits mailing list