Skip to content

Commit

Permalink
Fix limit behavior of dynamic alloca
Browse files Browse the repository at this point in the history
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
  • Loading branch information
serge-sans-paille committed Oct 2, 2020
1 parent 5829dc9 commit 9573c9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32394,7 +32394,7 @@ X86TargetLowering::EmitLoweredProbedAlloca(MachineInstr &MI,

BuildMI(testMBB, DL, TII->get(X86::JCC_1))
.addMBB(tailMBB)
.addImm(X86::COND_L);
.addImm(X86::COND_LE);
testMBB->addSuccessor(blockMBB);
testMBB->addSuccessor(tailMBB);

Expand Down
8 changes: 4 additions & 4 deletions llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ attributes #0 = {"probe-stack"="inline-asm"}
; CHECK-X86-64-NEXT: andq $-16, %rcx
; CHECK-X86-64-NEXT: subq %rcx, %rax
; CHECK-X86-64-NEXT: cmpq %rsp, %rax
; CHECK-X86-64-NEXT: jl .LBB0_3
; CHECK-X86-64-NEXT: jle .LBB0_3
; CHECK-X86-64-NEXT: .LBB0_2: # =>This Inner Loop Header: Depth=1
; CHECK-X86-64-NEXT: movq $0, (%rsp)
; CHECK-X86-64-NEXT: subq $4096, %rsp # imm = 0x1000
; CHECK-X86-64-NEXT: cmpq %rsp, %rax
; CHECK-X86-64-NEXT: jge .LBB0_2
; CHECK-X86-64-NEXT: jg .LBB0_2
; CHECK-X86-64-NEXT: .LBB0_3:
; CHECK-X86-64-NEXT: movq %rax, %rsp
; CHECK-X86-64-NEXT: movl $1, 4792(%rax)
Expand All @@ -54,12 +54,12 @@ attributes #0 = {"probe-stack"="inline-asm"}
; CHECK-X86-32-NEXT: andl $-16, %ecx
; CHECK-X86-32-NEXT: subl %ecx, %eax
; CHECK-X86-32-NEXT: cmpl %esp, %eax
; CHECK-X86-32-NEXT: jl .LBB0_3
; CHECK-X86-32-NEXT: jle .LBB0_3
; CHECK-X86-32-NEXT: .LBB0_2: # =>This Inner Loop Header: Depth=1
; CHECK-X86-32-NEXT: movl $0, (%esp)
; CHECK-X86-32-NEXT: subl $4096, %esp # imm = 0x1000
; CHECK-X86-32-NEXT: cmpl %esp, %eax
; CHECK-X86-32-NEXT: jge .LBB0_2
; CHECK-X86-32-NEXT: jg .LBB0_2
; CHECK-X86-32-NEXT: .LBB0_3:
; CHECK-X86-32-NEXT: movl %eax, %esp
; CHECK-X86-32-NEXT: movl $1, 4792(%eax)
Expand Down

0 comments on commit 9573c9f

Please sign in to comment.