[PATCH] D70741: [X86] [Win64] Avoid truncating large (> 32 bit) stack allocations

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 26 12:49:55 PST 2019


mstorsjo created this revision.
mstorsjo added reviewers: rnk, nagisa.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This fixes PR44129, which was broken in a7adc3185b (in 7.0.0 and newer).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70741

Files:
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/test/CodeGen/X86/win64-stackprobe-overflow.ll


Index: llvm/test/CodeGen/X86/win64-stackprobe-overflow.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/win64-stackprobe-overflow.ll
@@ -0,0 +1,14 @@
+; RUN: llc < %s -mtriple=x86_64-windows-gnu | FileCheck %s
+
+define void @foo() unnamed_addr #0 {
+start:
+  %b = alloca i64, align 8
+  %c = alloca [4294967295 x i8], align 1
+  ret void
+}
+
+attributes #0 = { nonlazybind uwtable "probe-stack"="probe_stack" "target-cpu"="x86-64" }
+
+; CHECK-LABEL: foo:
+; CHECK: movabsq $4294967304, %rax
+; CHECK-NEXT: callq probe_stack
Index: llvm/lib/Target/X86/X86FrameLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86FrameLowering.cpp
+++ llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -1261,7 +1261,7 @@
     if (Is64Bit) {
       // Handle the 64-bit Windows ABI case where we need to call __chkstk.
       // Function prologue is responsible for adjusting the stack pointer.
-      int Alloc = isEAXAlive ? NumBytes - 8 : NumBytes;
+      int64_t Alloc = isEAXAlive ? NumBytes - 8 : NumBytes;
       if (isUInt<32>(Alloc)) {
         BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), X86::EAX)
             .addImm(Alloc)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70741.231123.patch
Type: text/x-patch
Size: 1234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191126/a6299aa8/attachment.bin>


More information about the llvm-commits mailing list