[PATCH] D42512: [X86] When using Win64 ABI, exit with error if SSE is disabled for varargs

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 24 16:12:33 PST 2018


aemerson created this revision.
aemerson added reviewers: RKSimon, rnk, thegameg.

We need XMM registers to handle varargs with the Win64 ABI. Before we would silently generate bad code resulting in an assertion failure elsewhere in the backend.

@rnk @thegameg I see there was similar work in https://reviews.llvm.org/D27522 for register returns. I don't know if report_fatal_error is ok to do here, AFAICT there's no way to do something sensible but die in this situation.


Repository:
  rL LLVM

https://reviews.llvm.org/D42512

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/win64-nosse-error.ll


Index: test/CodeGen/X86/win64-nosse-error.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/win64-nosse-error.ll
@@ -0,0 +1,17 @@
+; RUN: not llc %s -mattr="-sse" 2>&1 | FileCheck %s
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-macho"
+
+; Function Attrs: noimplicitfloat noinline noredzone nounwind optnone
+define void @crash() #0 {
+  call void (i32*, ...) @func(i32* null, double undef)
+  ret void
+}
+; CHECK: LLVM ERROR: Win64 ABI varargs functions require SSE to be enabled
+; Function Attrs: noimplicitfloat noredzone
+declare void @func(i32*, ...)
+
+attributes #0 = { "target-cpu"="x86-64" "target-features"="-sse"}
+
+
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -3560,6 +3560,9 @@
     } else if (VA.isRegLoc()) {
       RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg));
       if (isVarArg && IsWin64) {
+        if (!Subtarget.hasSSE1())
+          report_fatal_error(
+              "Win64 ABI varargs functions require SSE to be enabled");
         // Win64 ABI requires argument XMM reg to be copied to the corresponding
         // shadow reg if callee is a varargs function.
         unsigned ShadowReg = 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42512.131373.patch
Type: text/x-patch
Size: 1394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180125/f3660639/attachment.bin>


More information about the llvm-commits mailing list