1# REQUIRES: ppc
2
3# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
4# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
5
6# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 32768
7# RUN: llvm-objdump -d %t | FileCheck %s
8# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 4096
9# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=SMALL
10# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 0
11# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=ZERO
12# RUN: not ld.lld %t1.o %t2.o -o /dev/null -split-stack-adjust-size -1 2>&1 | FileCheck %s -check-prefix=ERR
13# ERR: error: --split-stack-adjust-size: size must be >= 0
14
15# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
16# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
17
18# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 32768
19# RUN: llvm-objdump -d %t | FileCheck %s
20# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 4096
21# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=SMALL
22# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 0
23# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=ZERO
24        .p2align    2
25        .global caller
26        .type caller, @function
27caller:
28.Lcaller_gep:
29    addis 2, 12, .TOC.-.Lcaller_gep@ha
30    addi 2, 2, .TOC.-.Lcaller_gep@l
31    .localentry caller, .-caller
32    ld 0, -0x7040(13)
33    addi 12, 1, -32
34    nop
35    cmpld 7, 12, 0
36    blt- 7, .Lcaller_alloc_more
37.Lcaller_body:
38    mflr 0
39    std 0, 16(1)
40    stdu 1, -32(1)
41    bl nss_callee
42    addi 1, 1, 32
43    ld 0, 16(1)
44    mtlr 0
45    blr
46.Lcaller_alloc_more:
47    mflr 0
48    std 0, 16(1)
49    bl __morestack
50    ld 0, 16(1)
51    mtlr 0
52    blr
53    b .Lcaller_body
54        .size caller, .-caller
55
56# CHECK-LABEL: caller
57# CHECK:      ld 0, -28736(13)
58# CHECK-NEXT: addis 12, 1, -1
59# CHECK-NEXT: addi 12, 12, 32736
60# CHECK-NEXT: cmpld 7, 12, 0
61# CHECK-NEXT: bt- 28, 0x10010204
62
63# SMALL-LABEL: caller
64# SMALL:      ld 0, -28736(13)
65# SMALL-NEXT: addi 12, 1, -4128
66# SMALL-NEXT: nop
67# SMALL-NEXT: cmpld 7, 12, 0
68# SMALL-NEXT: bt- 28, 0x10010204
69
70# ZERO-LABEL: caller
71# ZERO:      ld 0, -28736(13)
72# ZERO-NEXT: addi 12, 1, -32
73# ZERO-NEXT: nop
74# ZERO-NEXT: cmpld 7, 12, 0
75# ZERO-NEXT: bt- 28, 0x10010204
76        .p2align    2
77        .global main
78	.type  main, @function
79main:
80.Lmain_gep:
81    addis 2,12,.TOC.-.Lmain_gep@ha
82    addi 2,2,.TOC.-.Lmain_gep@l
83    .localentry	main,.-main
84    ld 0,-0x7040(13)
85    addi 12,1,-32
86    nop
87    cmpld 7,12,0
88    blt- 7, .Lmain_morestack
89.Lmain_body:
90    mflr 0
91    std 0, 16(1)
92    stdu 1, -32(1)
93    bl caller
94    addi 1, 1, 32
95    ld 0, 16(1)
96    mtlr 0
97    blr
98.Lmain_morestack:
99    mflr 0
100    std 0, 16(1)
101    bl __morestack
102    ld 0, 16(1)
103    mtlr 0
104    blr
105    b .Lmain_body
106    .size main,.-main
107
108        .section        .note.GNU-split-stack,"",@progbits
109