Skip to content

Commit 8e51bf0

Browse files
serge-sans-pailletstellar
serge-sans-paille
authored andcommitted
Fix limit behavior of dynamic alloca
When the allocation size is 0, we shouldn't probe. Within [1, PAGE_SIZE], we should probe once etc. This fixes https://bugs.llvm.org/show_bug.cgi?id=47657 Differential Revision: https://reviews.llvm.org/D88548 (cherry picked from commit 9573c9f)
1 parent 973b95e commit 8e51bf0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31876,7 +31876,7 @@ X86TargetLowering::EmitLoweredProbedAlloca(MachineInstr &MI,
3187631876

3187731877
BuildMI(testMBB, DL, TII->get(X86::JCC_1))
3187831878
.addMBB(tailMBB)
31879-
.addImm(X86::COND_L);
31879+
.addImm(X86::COND_LE);
3188031880
testMBB->addSuccessor(blockMBB);
3188131881
testMBB->addSuccessor(tailMBB);
3188231882

llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ attributes #0 = {"probe-stack"="inline-asm"}
2424
; CHECK-X86-64-NEXT: andq $-16, %rcx
2525
; CHECK-X86-64-NEXT: subq %rcx, %rax
2626
; CHECK-X86-64-NEXT: cmpq %rsp, %rax
27-
; CHECK-X86-64-NEXT: jl .LBB0_3
27+
; CHECK-X86-64-NEXT: jle .LBB0_3
2828
; CHECK-X86-64-NEXT: .LBB0_2: # =>This Inner Loop Header: Depth=1
2929
; CHECK-X86-64-NEXT: movq $0, (%rsp)
3030
; CHECK-X86-64-NEXT: subq $4096, %rsp # imm = 0x1000
3131
; CHECK-X86-64-NEXT: cmpq %rsp, %rax
32-
; CHECK-X86-64-NEXT: jge .LBB0_2
32+
; CHECK-X86-64-NEXT: jg .LBB0_2
3333
; CHECK-X86-64-NEXT: .LBB0_3:
3434
; CHECK-X86-64-NEXT: movq %rax, %rsp
3535
; CHECK-X86-64-NEXT: movl $1, 4792(%rax)
@@ -54,12 +54,12 @@ attributes #0 = {"probe-stack"="inline-asm"}
5454
; CHECK-X86-32-NEXT: andl $-16, %ecx
5555
; CHECK-X86-32-NEXT: subl %ecx, %eax
5656
; CHECK-X86-32-NEXT: cmpl %esp, %eax
57-
; CHECK-X86-32-NEXT: jl .LBB0_3
57+
; CHECK-X86-32-NEXT: jle .LBB0_3
5858
; CHECK-X86-32-NEXT: .LBB0_2: # =>This Inner Loop Header: Depth=1
5959
; CHECK-X86-32-NEXT: movl $0, (%esp)
6060
; CHECK-X86-32-NEXT: subl $4096, %esp # imm = 0x1000
6161
; CHECK-X86-32-NEXT: cmpl %esp, %eax
62-
; CHECK-X86-32-NEXT: jge .LBB0_2
62+
; CHECK-X86-32-NEXT: jg .LBB0_2
6363
; CHECK-X86-32-NEXT: .LBB0_3:
6464
; CHECK-X86-32-NEXT: movl %eax, %esp
6565
; CHECK-X86-32-NEXT: movl $1, 4792(%eax)

0 commit comments

Comments
 (0)