diff options
author | Martin Storsjö <martin@martin.st> | 2019-11-26 22:41:40 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2019-11-27 10:44:42 +0200 |
commit | 943513b79929fba1a9dccdf81cb68a41ce29cd03 (patch) | |
tree | 244f8ba550bd47d75d2e626a2d5a3d74197a3639 | |
parent | 344bdeb797b31bb99158010f255a7219fe77e2ec (diff) | |
download | bcm5719-llvm-943513b79929fba1a9dccdf81cb68a41ce29cd03.tar.gz bcm5719-llvm-943513b79929fba1a9dccdf81cb68a41ce29cd03.zip |
[X86] [Win64] Avoid truncating large (> 32 bit) stack allocations
This fixes PR44129, which was broken in a7adc3185b (in 7.0.0
and newer).
Differential Revision: https://reviews.llvm.org/D70741
-rw-r--r-- | llvm/lib/Target/X86/X86FrameLowering.cpp | 2 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/win64-stackprobe-overflow.ll | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp index 3374cd054a6..799c1f5d128 100644 --- a/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -1261,7 +1261,7 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF, 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) diff --git a/llvm/test/CodeGen/X86/win64-stackprobe-overflow.ll b/llvm/test/CodeGen/X86/win64-stackprobe-overflow.ll new file mode 100644 index 00000000000..9555ce032db --- /dev/null +++ b/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 |