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 # RUN: ld.lld --defsym __morestack=0x10010000 %t1.o %t2.o -o %t
6 # RUN: llvm-objdump -d %t | FileCheck %s
8 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
9 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
10 # RUN: ld.lld --defsym __morestack=0x10010000 %t1.o %t2.o -o %t
11 # RUN: llvm-objdump -d %t | FileCheck %s
17 # A caller with a stack that is small enough that the addis instruction
18 # from the split-stack prologue is unneeded, and after the prologue adjustment
19 # the stack size still fits within 16 bits.
21 .global caller_small_stack
22 .type caller_small_stack, @function
25 addis 2, 12, .TOC.-.Lcss_gep@ha
26 addi 2, 2, .TOC.-.Lcss_gep@l
27 .localentry caller_small_stack, .-caller_small_stack
32 blt- 7, .Lcss_alloc_more
50 .size caller_small_stack, .-caller_small_stack
52 # CHECK-LABEL: caller_small_stack
53 # CHECK: ld 0, -28736(13)
54 # CHECK-NEXT: addi 12, 1, -16416
56 # CHECK-NEXT: cmpld 7, 12, 0
57 # CHECK-NEXT: bt- 28, 0x10010204
59 # A caller that has a stack size that fits within 16 bits, but the adjusted
60 # stack size after prologue adjustment now overflows 16 bits needing both addis
61 # and addi instructions.
63 .global caller_med_stack
64 .type caller_med_stack, @function
67 addis 2, 12, .TOC.-.Lcms_gep@ha
68 addi 12, 12, .TOC.-.Lcms_gep@l
69 .localentry caller_med_stack, .-caller_med_stack
74 blt- 7, .Lcms_alloc_more
92 .size caller_med_stack, .-caller_med_stack
94 # A caller with a large enough stack frame that both the addis and
95 # addi instructions are used in the split-stack prologue.
97 .global caller_large_stack
98 .type caller_large_stack, @function
101 addis 2, 12, .TOC.-.Lcls_gep@ha
102 addi 12, 12, .TOC.-.Lcls_gep@l
103 .localentry caller_large_stack, .-caller_large_stack
108 blt- 7, .Lcls_alloc_more
128 .size caller_large_stack, .-caller_large_stack
130 # CHECK-LABEL: caller_large_stack
131 # CHECK: ld 0, -28736(13)
132 # CHECK-NEXT: addis 12, 1, -1
133 # CHECK-NEXT: addi 12, 12, -16416
134 # CHECK-NEXT: cmpld 7, 12, 0
135 # CHECK-NEXT: bt- 28, 0x100102bc
137 # A caller with a stack size that is larger then 16 bits, but aligned such that
138 # the addi instruction is unneeded.
140 .global caller_large_aligned_stack
141 .type caller_large_aligned_stack, @function
142 caller_large_aligned_stack
:
144 addis 2, 12, .TOC.-.Lclas_gep@ha
145 addi 12, 12, .TOC.-.Lclas_gep@l
146 .localentry caller_large_aligned_stack, .-caller_large_aligned_stack
151 blt- 7, .Lclas_alloc_more
170 .size caller_large_aligned_stack, .-caller_large_aligned_stack
172 # CHECK-LABEL: caller_large_aligned_stack
173 # CHECK: ld 0, -28736(13)
174 # CHECK-NEXT: addis 12, 1, -2
175 # CHECK-NEXT: addi 12, 12, -16384
176 # CHECK-NEXT: cmpld 7, 12, 0
177 # CHECK-NEXT: bt- 28, 0x10010318
179 # main only calls split-stack functions or __morestack so
180 # there should be no adjustment of its split-stack prologue.
183 .type main, @function
186 addis 2, 12,.TOC.-.Lmain_gep@ha
187 addi 2, 2,.TOC.-.Lmain_gep@l
188 .localentry main,.-main
193 blt- 7, .Lmain_morestack
198 bl caller_small_stack
202 bl caller_large_stack
204 bl caller_large_aligned_stack
219 # CHECK: ld 0, -28736(13)
220 # CHECK-NEXT: addi 12, 1, -32
222 # CHECK-NEXT: cmpld 7, 12, 0
224 .section .note.GNU-split-stack,"",@progbits