[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / ppc64-split-stack-prologue-adjust-success.s
blob002f80d5cb8012796acefd81f96593d1d86d9f77
1 # REQUIRES: ppc
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
13 .abiversion 2
14 .section ".text"
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.
20 .p2align 2
21 .global caller_small_stack
22 .type caller_small_stack, @function
23 caller_small_stack:
24 .Lcss_gep:
25 addis 2, 12, .TOC.-.Lcss_gep@ha
26 addi 2, 2, .TOC.-.Lcss_gep@l
27 .localentry caller_small_stack, .-caller_small_stack
28 ld 0, -0x7040(13)
29 addi 12, 1, -32
30 nop
31 cmpld 7, 12, 0
32 blt- 7, .Lcss_alloc_more
33 .Lcss_body:
34 mflr 0
35 std 0, 16(1)
36 stdu 1, -32(1)
37 bl nss_callee
38 addi 1, 1, 32
39 ld 0, 16(1)
40 mtlr 0
41 blr
42 .Lcss_alloc_more:
43 mflr 0
44 std 0, 16(1)
45 bl __morestack
46 ld 0, 16(1)
47 mtlr 0
48 blr
49 b .Lcss_body
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
55 # CHECK-NEXT: nop
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.
62 .p2align 2
63 .global caller_med_stack
64 .type caller_med_stack, @function
65 caller_med_stack:
66 .Lcms_gep:
67 addis 2, 12, .TOC.-.Lcms_gep@ha
68 addi 12, 12, .TOC.-.Lcms_gep@l
69 .localentry caller_med_stack, .-caller_med_stack
70 ld 0, -0x7040(13)
71 addi 12, 1, -32764
72 nop
73 cmpld 7, 12, 0
74 blt- 7, .Lcms_alloc_more
75 .Lcms_body:
76 mflr 0
77 std 0, 16(1)
78 stdu 1, -32764(1)
79 bl nss_callee
80 addi 1, 1, 32764
81 ld 0, 16(1)
82 mtlr 0
83 blr
84 .Lcms_alloc_more:
85 mflr 0
86 std 0, 16(1)
87 bl __morestack
88 ld 0, 16(1)
89 mtlr 0
90 blr
91 b .Lcms_body
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.
96 .p2align 2
97 .global caller_large_stack
98 .type caller_large_stack, @function
99 caller_large_stack:
100 .Lcls_gep:
101 addis 2, 12, .TOC.-.Lcls_gep@ha
102 addi 12, 12, .TOC.-.Lcls_gep@l
103 .localentry caller_large_stack, .-caller_large_stack
104 ld 0, -0x7040(13)
105 addis 12, 1, -1
106 addi 12, 12, -32
107 cmpld 7, 12, 0
108 blt- 7, .Lcls_alloc_more
109 .Lcls_body:
110 mflr 0
111 std 0, 16(1)
112 lis 0, -1
113 addi 0, 0, -32
114 stdux 1, 0, 1
115 bl nss_callee
116 ld 1, 0(1)
117 ld 0, 16(1)
118 mtlr 0
120 .Lcls_alloc_more:
121 mflr 0
122 std 0, 16(1)
123 bl __morestack
124 ld 0, 16(1)
125 mtlr 0
127 b .Lcls_body
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.
139 .p2align 2
140 .global caller_large_aligned_stack
141 .type caller_large_aligned_stack, @function
142 caller_large_aligned_stack:
143 .Lclas_gep:
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
147 ld 0, -0x7040(13)
148 addis 12, 1, -2
150 cmpld 7, 12, 0
151 blt- 7, .Lclas_alloc_more
152 .Lclas_body:
153 mflr 0
154 std 0, 16(1)
155 lis 0, -2
156 stdux 1, 0, 1
157 bl nss_callee
158 ld 1, 0(1)
159 ld 0, 16(1)
160 mtlr 0
162 .Lclas_alloc_more:
163 mflr 0
164 std 0, 16(1)
165 bl __morestack
166 ld 0, 16(1)
167 mtlr 0
169 b .Lclas_body
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.
181 .p2align 2
182 .global main
183 .type main, @function
184 main:
185 .Lmain_gep:
186 addis 2, 12,.TOC.-.Lmain_gep@ha
187 addi 2, 2,.TOC.-.Lmain_gep@l
188 .localentry main,.-main
189 ld 0, -0x7040(13)
190 addi 12,1,-32
192 cmpld 7, 12,0
193 blt- 7, .Lmain_morestack
194 .Lmain_body:
195 mflr 0
196 std 0, 16(1)
197 stdu 1, -32(1)
198 bl caller_small_stack
200 bl caller_med_stack
202 bl caller_large_stack
204 bl caller_large_aligned_stack
205 addi 1, 1, 32
206 ld 0, 16(1)
207 mtlr 0
209 .Lmain_morestack:
210 mflr 0
211 std 0, 16(1)
212 bl __morestack
213 ld 0, 16(1)
214 mtlr 0
216 b .Lmain_body
217 .size main,.-main
218 # CHECK-LABEL: main
219 # CHECK: ld 0, -28736(13)
220 # CHECK-NEXT: addi 12, 1, -32
221 # CHECK-NEXT: nop
222 # CHECK-NEXT: cmpld 7, 12, 0
224 .section .note.GNU-split-stack,"",@progbits