2 # RUN: split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/callees.s -o %t-callees.o
5 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/callertoc.s -o %t-callertoc.o
6 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/callernotoc.s -o %t-callernotoc.o
7 # RUN: ld.lld -T %t/lds %t-callees.o %t-callernotoc.o %t-callertoc.o -o %t-r12setup
8 # RUN: ld.lld -T %t/ldsswap %t-callees.o %t-callernotoc.o %t-callertoc.o -o %t-r2save
10 # RUN: llvm-objdump -d --no-show-raw-insn %t-r12setup | \
11 # RUN: FileCheck %s --check-prefix=NOSWAP
12 # RUN: llvm-objdump -d --no-show-raw-insn %t-r2save | \
13 # RUN: FileCheck %s --check-prefix=SWAP
15 ## This test checks that it is possible to mix TOC and NOTOC functions and have
16 ## the correct thunks for all of the calls.
18 # NOSWAP-LABEL: 01001000 <func>:
20 # NOSWAP-LABEL: 01002000 <callee_toc>:
21 # NOSWAP: bl 0x1001000
23 # NOSWAP-LABEL: 01002018 <callee_notoc>:
24 # NOSWAP: bl 0x1001000
26 # NOSWAP-LABEL: 10030000 <caller_notoc>:
27 # NOSWAP-NEXT: bl 0x10030010
28 # NOSWAP-NEXT: bl 0x10030030
30 # NOSWAP-LABEL: 10030010 <__gep_setup_callee_toc>:
32 # NOSWAP-LABEL: 10030030 <__gep_setup_callee_notoc>:
34 # NOSWAP-LABEL: 10040000 <caller_toc>:
35 # NOSWAP: bl 0x10040020
37 # NOSWAP-NEXT: bl 0x10040040
38 # NOSWAP-NEXT: ld 2, 24(1)
40 # NOSWAP-LABEL: 10040020 <__long_branch_callee_toc>:
42 # NOSWAP-LABEL: 10040040 <__toc_save_callee_notoc>:
43 # NOSWAP-NEXT: std 2, 24(1)
46 # SWAP-LABEL: 01001000 <func>:
48 # SWAP-LABEL: 01002000 <callee_toc>:
51 # SWAP-LABEL: 01002018 <callee_notoc>:
54 # SWAP-LABEL: 10030000 <caller_toc>:
57 # SWAP-NEXT: bl 0x10030040
58 # SWAP-NEXT: ld 2, 24(1)
60 # SWAP-LABEL: 10030020 <__long_branch_callee_toc>:
62 # SWAP-LABEL: 10030040 <__toc_save_callee_notoc>:
63 # SWAP-NEXT: std 2, 24(1)
65 # SWAP-LABEL: 10040000 <caller_notoc>:
66 # SWAP-NEXT: bl 0x10040010
67 # SWAP-NEXT: bl 0x10040030
69 # SWAP-LABEL: 10040010 <__gep_setup_callee_toc>:
71 # SWAP-LABEL: 10040030 <__gep_setup_callee_notoc>:
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) }
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) }
91 .section .text_func, "ax", %progbits
96 .section .text_callee, "ax", %progbits
99 addis 2, 12, .TOC.-.Lfunc_gep1@ha
100 addi 2, 2, .TOC.-.Lfunc_gep1@l
102 .localentry callee_toc, .Lfunc_lep1-.Lfunc_gep1
104 addis 4, 2, global@toc@ha
105 lwz 4, global@toc@
l(4)
110 .localentry callee_notoc, 1
112 plwz
4, global@pcrel
(0), 1
121 .section .text_caller_notoc, "ax", %progbits
123 .localentry caller, 1
125 bl callee_notoc@notoc
129 .section .text_caller_toc, "ax", %progbits
132 addis 2, 12, .TOC.-.Lfunc_gep2@ha
133 addi 2, 2, .TOC.-.Lfunc_gep2@l
135 .localentry caller_toc, .Lfunc_lep2-.Lfunc_gep2