Skip to content

Commit

Permalink
[X86] improve split-stack machine BB placement
Browse files Browse the repository at this point in the history
Summary:
The conditional branch created to support -fsplit-stack for X86 is
left unbiased/unhinted, resulting in less than ideal block placement:
the __morestack call block is kept on the main hot path. Bias the
branch to insure that the stack allocation block is treated as a
"cold" block during machine basic block placement.

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D54123

llvm-svn: 346336
  • Loading branch information
thanm committed Nov 7, 2018
1 parent ac86038 commit 5bcdea5
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 82 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/X86/X86FrameLowering.cpp
Expand Up @@ -2471,8 +2471,8 @@ void X86FrameLowering::adjustForSegmentedStacks(

allocMBB->addSuccessor(&PrologueMBB);

checkMBB->addSuccessor(allocMBB);
checkMBB->addSuccessor(&PrologueMBB);
checkMBB->addSuccessor(allocMBB, BranchProbability::getZero());
checkMBB->addSuccessor(&PrologueMBB, BranchProbability::getOne());

#ifdef EXPENSIVE_CHECKS
MF.verify();
Expand Down
36 changes: 18 additions & 18 deletions llvm/test/CodeGen/X86/segmented-stacks-dynamic.ll
Expand Up @@ -25,12 +25,7 @@ false:
; X32-LABEL: test_basic:

; X32: cmpl %gs:48, %esp
; X32-NEXT: ja .LBB0_2

; X32: pushl $4
; X32-NEXT: pushl $12
; X32-NEXT: calll __morestack
; X32-NEXT: ret
; X32-NEXT: jbe .LBB0_1

; X32: movl %esp, %eax
; X32: subl %ecx, %eax
Expand All @@ -43,15 +38,15 @@ false:
; X32-NEXT: calll __morestack_allocate_stack_space
; X32-NEXT: addl $16, %esp

; X32: pushl $4
; X32-NEXT: pushl $12
; X32-NEXT: calll __morestack
; X32-NEXT: ret

; X64-LABEL: test_basic:

; X64: cmpq %fs:112, %rsp
; X64-NEXT: ja .LBB0_2

; X64: movabsq $24, %r10
; X64-NEXT: movabsq $0, %r11
; X64-NEXT: callq __morestack
; X64-NEXT: ret
; X64-NEXT: jbe .LBB0_1

; X64: movq %rsp, %[[RDI:rdi|rax]]
; X64: subq %{{.*}}, %[[RDI]]
Expand All @@ -63,15 +58,15 @@ false:
; X64-NEXT: callq __morestack_allocate_stack_space
; X64: movq %rax, %rdi

; X64: movabsq $24, %r10
; X64-NEXT: movabsq $0, %r11
; X64-NEXT: callq __morestack
; X64-NEXT: ret

; X32ABI-LABEL: test_basic:

; X32ABI: cmpl %fs:64, %esp
; X32ABI-NEXT: ja .LBB0_2

; X32ABI: movl $24, %r10d
; X32ABI-NEXT: movl $0, %r11d
; X32ABI-NEXT: callq __morestack
; X32ABI-NEXT: ret
; X32ABI-NEXT: jbe .LBB0_1

; X32ABI: movl %esp, %[[EDI:edi|eax]]
; X32ABI: subl %{{.*}}, %[[EDI]]
Expand All @@ -83,6 +78,11 @@ false:
; X32ABI-NEXT: callq __morestack_allocate_stack_space
; X32ABI: movl %eax, %edi

; X32ABI: movl $24, %r10d
; X32ABI-NEXT: movl $0, %r11d
; X32ABI-NEXT: callq __morestack
; X32ABI-NEXT: ret

}

attributes #0 = { "split-stack" }

0 comments on commit 5bcdea5

Please sign in to comment.