225 lines · plain
1# REQUIRES: ppc2 3# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o4# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o5# RUN: ld.lld --defsym __morestack=0x10010000 %t1.o %t2.o -o %t6# RUN: llvm-objdump -d %t | FileCheck %s7 8# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o9# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o10# RUN: ld.lld --defsym __morestack=0x10010000 %t1.o %t2.o -o %t11# RUN: llvm-objdump -d %t | FileCheck %s12 13 .abiversion 214 .section ".text"15 16 17# A caller with a stack that is small enough that the addis instruction18# from the split-stack prologue is unneeded, and after the prologue adjustment19# the stack size still fits within 16 bits.20 .p2align 221 .global caller_small_stack22 .type caller_small_stack, @function23caller_small_stack:24.Lcss_gep:25 addis 2, 12, .TOC.-.Lcss_gep@ha26 addi 2, 2, .TOC.-.Lcss_gep@l27 .localentry caller_small_stack, .-caller_small_stack28 ld 0, -0x7040(13)29 addi 12, 1, -3230 nop31 cmpld 7, 12, 032 blt- 7, .Lcss_alloc_more33.Lcss_body:34 mflr 035 std 0, 16(1)36 stdu 1, -32(1)37 bl nss_callee38 addi 1, 1, 3239 ld 0, 16(1)40 mtlr 041 blr42.Lcss_alloc_more:43 mflr 044 std 0, 16(1)45 bl __morestack46 ld 0, 16(1)47 mtlr 048 blr49 b .Lcss_body50 .size caller_small_stack, .-caller_small_stack51 52# CHECK-LABEL: caller_small_stack53# CHECK: ld 0, -28736(13)54# CHECK-NEXT: addi 12, 1, -1641655# CHECK-NEXT: nop56# CHECK-NEXT: cmpld 7, 12, 057# CHECK-NEXT: bt- 28, 0x1001020458 59# A caller that has a stack size that fits within 16 bits, but the adjusted60# stack size after prologue adjustment now overflows 16 bits needing both addis61# and addi instructions.62 .p2align 263 .global caller_med_stack64 .type caller_med_stack, @function65caller_med_stack:66.Lcms_gep:67 addis 2, 12, .TOC.-.Lcms_gep@ha68 addi 12, 12, .TOC.-.Lcms_gep@l69 .localentry caller_med_stack, .-caller_med_stack70 ld 0, -0x7040(13)71 addi 12, 1, -3276472 nop73 cmpld 7, 12, 074 blt- 7, .Lcms_alloc_more75.Lcms_body:76 mflr 077 std 0, 16(1)78 stdu 1, -32764(1)79 bl nss_callee80 addi 1, 1, 3276481 ld 0, 16(1)82 mtlr 083 blr84.Lcms_alloc_more:85 mflr 086 std 0, 16(1)87 bl __morestack88 ld 0, 16(1)89 mtlr 090 blr91 b .Lcms_body92 .size caller_med_stack, .-caller_med_stack93 94# A caller with a large enough stack frame that both the addis and95# addi instructions are used in the split-stack prologue.96 .p2align 297 .global caller_large_stack98 .type caller_large_stack, @function99caller_large_stack:100.Lcls_gep:101 addis 2, 12, .TOC.-.Lcls_gep@ha102 addi 12, 12, .TOC.-.Lcls_gep@l103 .localentry caller_large_stack, .-caller_large_stack104 ld 0, -0x7040(13)105 addis 12, 1, -1106 addi 12, 12, -32107 cmpld 7, 12, 0108 blt- 7, .Lcls_alloc_more109.Lcls_body:110 mflr 0111 std 0, 16(1)112 lis 0, -1113 addi 0, 0, -32114 stdux 1, 0, 1115 bl nss_callee116 ld 1, 0(1)117 ld 0, 16(1)118 mtlr 0119 blr120.Lcls_alloc_more:121 mflr 0122 std 0, 16(1)123 bl __morestack124 ld 0, 16(1)125 mtlr 0126 blr127 b .Lcls_body128 .size caller_large_stack, .-caller_large_stack129 130# CHECK-LABEL: caller_large_stack131# CHECK: ld 0, -28736(13)132# CHECK-NEXT: addis 12, 1, -1133# CHECK-NEXT: addi 12, 12, -16416134# CHECK-NEXT: cmpld 7, 12, 0135# CHECK-NEXT: bt- 28, 0x100102bc136 137# A caller with a stack size that is larger then 16 bits, but aligned such that138# the addi instruction is unneeded.139 .p2align 2140 .global caller_large_aligned_stack141 .type caller_large_aligned_stack, @function142caller_large_aligned_stack:143.Lclas_gep:144 addis 2, 12, .TOC.-.Lclas_gep@ha145 addi 12, 12, .TOC.-.Lclas_gep@l146 .localentry caller_large_aligned_stack, .-caller_large_aligned_stack147 ld 0, -0x7040(13)148 addis 12, 1, -2149 nop150 cmpld 7, 12, 0151 blt- 7, .Lclas_alloc_more152.Lclas_body:153 mflr 0154 std 0, 16(1)155 lis 0, -2156 stdux 1, 0, 1157 bl nss_callee158 ld 1, 0(1)159 ld 0, 16(1)160 mtlr 0161 blr162.Lclas_alloc_more:163 mflr 0164 std 0, 16(1)165 bl __morestack166 ld 0, 16(1)167 mtlr 0168 blr169 b .Lclas_body170 .size caller_large_aligned_stack, .-caller_large_aligned_stack171 172# CHECK-LABEL: caller_large_aligned_stack173# CHECK: ld 0, -28736(13)174# CHECK-NEXT: addis 12, 1, -2175# CHECK-NEXT: addi 12, 12, -16384176# CHECK-NEXT: cmpld 7, 12, 0177# CHECK-NEXT: bt- 28, 0x10010318178 179# main only calls split-stack functions or __morestack so180# there should be no adjustment of its split-stack prologue.181 .p2align 2182 .global main183 .type main, @function184main:185.Lmain_gep:186 addis 2, 12,.TOC.-.Lmain_gep@ha187 addi 2, 2,.TOC.-.Lmain_gep@l188 .localentry main,.-main189 ld 0, -0x7040(13)190 addi 12,1,-32191 nop192 cmpld 7, 12,0193 blt- 7, .Lmain_morestack194.Lmain_body:195 mflr 0196 std 0, 16(1)197 stdu 1, -32(1)198 bl caller_small_stack199 nop200 bl caller_med_stack201 nop202 bl caller_large_stack203 nop204 bl caller_large_aligned_stack205 addi 1, 1, 32206 ld 0, 16(1)207 mtlr 0208 blr209.Lmain_morestack:210 mflr 0211 std 0, 16(1)212 bl __morestack213 ld 0, 16(1)214 mtlr 0215 blr216 b .Lmain_body217 .size main,.-main218# CHECK-LABEL: main219# CHECK: ld 0, -28736(13)220# CHECK-NEXT: addi 12, 1, -32221# CHECK-NEXT: nop222# CHECK-NEXT: cmpld 7, 12, 0223 224 .section .note.GNU-split-stack,"",@progbits225