141 lines · plain
1# REQUIRES: ppc2# RUN: split-file %s %t3 4# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/callees.s -o %t-callees.o5# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/callertoc.s -o %t-callertoc.o6# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/callernotoc.s -o %t-callernotoc.o7# RUN: ld.lld -T %t/lds %t-callees.o %t-callernotoc.o %t-callertoc.o -o %t-r12setup8# RUN: ld.lld -T %t/ldsswap %t-callees.o %t-callernotoc.o %t-callertoc.o -o %t-r2save9 10# RUN: llvm-objdump -d --no-show-raw-insn %t-r12setup | \11# RUN: FileCheck %s --check-prefix=NOSWAP12# RUN: llvm-objdump -d --no-show-raw-insn %t-r2save | \13# RUN: FileCheck %s --check-prefix=SWAP14 15## This test checks that it is possible to mix TOC and NOTOC functions and have16## the correct thunks for all of the calls.17 18# NOSWAP-LABEL: 01001000 <func>:19# NOSWAP-NEXT: blr20# NOSWAP-LABEL: 01002000 <callee_toc>:21# NOSWAP: bl 0x100100022# NOSWAP: blr23# NOSWAP-LABEL: 01002018 <callee_notoc>:24# NOSWAP: bl 0x100100025# NOSWAP: blr26# NOSWAP-LABEL: 10030000 <caller_notoc>:27# NOSWAP-NEXT: bl 0x1003001028# NOSWAP-NEXT: bl 0x1003003029# NOSWAP-NEXT: blr30# NOSWAP-LABEL: 10030010 <__gep_setup_callee_toc>:31# NOSWAP: bctr32# NOSWAP-LABEL: 10030030 <__gep_setup_callee_notoc>:33# NOSWAP: bctr34# NOSWAP-LABEL: 10040000 <caller_toc>:35# NOSWAP: bl 0x1004002036# NOSWAP-NEXT: nop37# NOSWAP-NEXT: bl 0x1004004038# NOSWAP-NEXT: ld 2, 24(1)39# NOSWAP-NEXT: blr40# NOSWAP-LABEL: 10040020 <__long_branch_callee_toc>:41# NOSWAP: bctr42# NOSWAP-LABEL: 10040040 <__toc_save_callee_notoc>:43# NOSWAP-NEXT: std 2, 24(1)44# NOSWAP: bctr45 46# SWAP-LABEL: 01001000 <func>:47# SWAP-NEXT: blr48# SWAP-LABEL: 01002000 <callee_toc>:49# SWAP: bl 0x100100050# SWAP: blr51# SWAP-LABEL: 01002018 <callee_notoc>:52# SWAP: bl 0x100100053# SWAP: blr54# SWAP-LABEL: 10030000 <caller_toc>:55# SWAP: bl 0x1003002056# SWAP-NEXT: nop57# SWAP-NEXT: bl 0x1003004058# SWAP-NEXT: ld 2, 24(1)59# SWAP-NEXT: blr60# SWAP-LABEL: 10030020 <__long_branch_callee_toc>:61# SWAP: bctr62# SWAP-LABEL: 10030040 <__toc_save_callee_notoc>:63# SWAP-NEXT: std 2, 24(1)64# SWAP: bctr65# SWAP-LABEL: 10040000 <caller_notoc>:66# SWAP-NEXT: bl 0x1004001067# SWAP-NEXT: bl 0x1004003068# SWAP-NEXT: blr69# SWAP-LABEL: 10040010 <__gep_setup_callee_toc>:70# SWAP: bctr71# SWAP-LABEL: 10040030 <__gep_setup_callee_notoc>:72# SWAP: bctr73 74#--- lds75SECTIONS {76 .text_func 0x1001000 : { *(.text_func) }77 .text_callee 0x1002000 : { *(.text_callee) }78 .text_caller_notoc 0x10030000 : { *(.text_caller_notoc) }79 .text_caller_toc 0x10040000 : { *(.text_caller_toc) }80}81 82#--- ldsswap83SECTIONS {84 .text_func 0x1001000 : { *(.text_func) }85 .text_callee 0x1002000 : { *(.text_callee) }86 .text_caller_toc 0x10030000 : { *(.text_caller_toc) }87 .text_caller_notoc 0x10040000 : { *(.text_caller_notoc) }88}89 90#--- callees.s91.section .text_func, "ax", %progbits92func:93 blr94 95.globl callee_toc96.section .text_callee, "ax", %progbits97callee_toc:98.Lfunc_gep1:99 addis 2, 12, .TOC.-.Lfunc_gep1@ha100 addi 2, 2, .TOC.-.Lfunc_gep1@l101.Lfunc_lep1:102 .localentry callee_toc, .Lfunc_lep1-.Lfunc_gep1103 bl func104 addis 4, 2, global@toc@ha105 lwz 4, global@toc@l(4)106 blr107 108.globl callee_notoc109callee_notoc:110 .localentry callee_notoc, 1111 bl func112 plwz 4, global@pcrel(0), 1113 blr114 115## .globl global116global:117 .long 0118 .size global, 4119 120#--- callernotoc.s121.section .text_caller_notoc, "ax", %progbits122caller_notoc:123 .localentry caller, 1124 bl callee_toc@notoc125 bl callee_notoc@notoc126 blr127 128#--- callertoc.s129.section .text_caller_toc, "ax", %progbits130caller_toc:131.Lfunc_gep2:132 addis 2, 12, .TOC.-.Lfunc_gep2@ha133 addi 2, 2, .TOC.-.Lfunc_gep2@l134.Lfunc_lep2:135 .localentry caller_toc, .Lfunc_lep2-.Lfunc_gep2136 bl callee_toc137 nop138 bl callee_notoc139 nop140 blr141