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: not ld.lld %t1.o %t2.o -o /dev/null --defsym __morestack=0x10010000 2>&1 | \
7# RUN: FileCheck -check-prefix=OVERFLOW %s
8# RUN: not ld.lld %t1.o %t2.o -o /dev/null --defsym __morestack=0x10010000 \
9# RUN: -split-stack-adjust-size 4097 2>&1 | FileCheck -check-prefix=OVERFLOW %s
10# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 4096
11# RUN: llvm-objdump -d %t | FileCheck %s
12
13# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
14# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
15
16# RUN: not ld.lld %t1.o %t2.o -o /dev/null --defsym __morestack=0x10010000 2>&1 | \
17# RUN: FileCheck -check-prefix=OVERFLOW %s
18# RUN: not ld.lld %t1.o %t2.o -o /dev/null --defsym __morestack=0x10010000 \
19# RUN: -split-stack-adjust-size 4097 2>&1 | FileCheck -check-prefix=OVERFLOW %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
22
23# OVERFLOW: error: {{.*}}.o:(function caller: .text+0x8): split-stack prologue adjustment overflows
24
25        .p2align    2
26        .global caller
27        .type caller, @function
28caller:
29.Lcaller_gep:
30    addis 2, 12, .TOC.-.Lcaller_gep@ha
31    addi 2, 2, .TOC.-.Lcaller_gep@l
32    .localentry caller, .-caller
33    ld 0, -0x7040(13)
34    addis 12, 1, -32768
35    addi  12, 12, 4096
36    cmpld 7, 12, 0
37    blt- 7, .Lcaller_alloc_more
38.Lcaller_body:
39    mflr 0
40    std 0, 16(1)
41    stdu 1, -32(1)
42    bl nss_callee
43    addi 1, 1, 32
44    ld 0, 16(1)
45    mtlr 0
46    blr
47.Lcaller_alloc_more:
48    mflr 0
49    std 0, 16(1)
50    bl __morestack
51    ld 0, 16(1)
52    mtlr 0
53    blr
54    b .Lcaller_body
55        .size caller, .-caller
56
57# CHECK-LABEL: caller
58# CHECK:      ld 0, -28736(13)
59# CHECK-NEXT: addis 12, 1, -32768
60# CHECK-NEXT: nop
61# CHECK-NEXT: cmpld 7, 12, 0
62# CHECK-NEXT: bt- 28, 0x10010204
63
64.section        .note.GNU-split-stack,"",@progbits
65