[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / ppc64-toc-call-to-pcrel-long-jump.s
blobf8810130fa9c24b93431d89e184348b230da6e97
1 # REQUIRES: ppc
2 # RUN: split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o
5 # RUN: ld.lld -T %t/lts %t.o -o %t_le
6 # RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_le | FileCheck %s
7 # RUN: llvm-readelf -s %t_le | FileCheck %s --check-prefix=SYM
9 # RUN: llvm-mc -filetype=obj -triple=powerpc64 %t/asm -o %t.o
10 # RUN: ld.lld -T %t/lts %t.o -o %t_be
11 # RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_be | FileCheck %s
12 # RUN: llvm-readelf -s %t_be | FileCheck %s --check-prefix=SYM
14 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o
15 # RUN: ld.lld -T %t/lts %t.o -o %t_le --no-power10-stubs
16 # RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_le | FileCheck %s --check-prefix=NoP10
17 # RUN: llvm-readelf -s %t_le | FileCheck %s --check-prefix=SYM
19 # SYM: Symbol table '.symtab' contains 9 entries:
20 # SYM: 1: 0000000010010000 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 1 callee
21 # SYM-NEXT: 2: 0000000010020008 0 NOTYPE LOCAL DEFAULT 2 caller_close
22 # SYM-NEXT: 3: 0000000020020008 0 NOTYPE LOCAL DEFAULT [<other: 0x60>] 3 caller
23 # SYM-NEXT: 4: 0000000520020008 0 NOTYPE LOCAL DEFAULT 4 caller_far
24 # SYM-NEXT: 5: 0000000520028040 0 NOTYPE LOCAL HIDDEN 6 .TOC.
25 # SYM-NEXT: 6: 0000000010020020 8 FUNC LOCAL DEFAULT 2 __toc_save_callee
26 # SYM-NEXT: 7: 0000000020020020 32 FUNC LOCAL DEFAULT 3 __toc_save_callee
27 # SYM-NEXT: 8: 0000000520020020 32 FUNC LOCAL DEFAULT 4 __toc_save_callee
29 #--- lts
30 PHDRS {
31 callee PT_LOAD FLAGS(0x1 | 0x4);
32 close PT_LOAD FLAGS(0x1 | 0x4);
33 caller PT_LOAD FLAGS(0x1 | 0x4);
34 far PT_LOAD FLAGS(0x1 | 0x4);
36 SECTIONS {
37 .text_callee 0x10010000 : { *(.text_callee) } :callee
38 .text_caller_close 0x10020000 : { *(.text_caller_close) } :close
39 .text_caller 0x20020000 : { *(.text_caller) } :caller
40 .text_caller_far 0x520020000 : { *(.text_caller_far) } :far
43 #--- asm
44 # CHECK-LABEL: <callee>:
45 # CHECK: blr
46 .section .text_callee, "ax", %progbits
47 callee:
48 .localentry callee, 1
49 blr
51 # CHECK-LABEL: <caller_close>:
52 # CHECK: bl 0x10020020
53 # CHECK-NEXT: ld 2, 24(1)
54 # CHECK-NEXT: blr
55 # CHECK-LABEL: <__toc_save_callee>:
56 # CHECK: std 2, 24(1)
57 # CHECK-NEXT: b 0x10010000
58 .section .text_caller_close, "ax", %progbits
59 .Lfunc_toc1:
60 .quad .TOC.-.Lfunc_gep1
61 caller_close:
62 .Lfunc_gep1:
63 ld 2, .Lfunc_toc1-.Lfunc_gep1(12)
64 add 2, 2, 12
65 .Lfunc_lep1:
66 .localentry caller, .Lfunc_lep1-.Lfunc_gep1
67 bl callee
68 nop
69 blr
71 # CHECK-LABEL: <caller>:
72 # CHECK: bl 0x20020020
73 # CHECK-NEXT: ld 2, 24(1)
74 # CHECK-NEXT: blr
75 # CHECK-LABEL: <__toc_save_callee>:
76 # CHECK: std 2, 24(1)
77 # CHECK-NEXT: paddi 12, 0, -268501028, 1
78 # CHECK-NEXT: mtctr 12
79 # CHECK-NEXT: bctr
81 # NoP10-LABEL: <caller>:
82 # NoP10: bl 0x20020020
83 # NoP10-NEXT: ld 2, 24(1)
84 # NoP10-NEXT: blr
85 # NoP10-LABEL: <__toc_save_callee>:
86 # NoP10-NEXT: std 2, 24(1)
87 # NoP10-NEXT: addis 12, 2, -4098
88 # NoP10-NEXT: addi 12, 12, 32704
89 # NoP10-NEXT: mtctr 12
90 # NoP10-NEXT: bctr
91 .section .text_caller, "ax", %progbits
92 .Lfunc_toc2:
93 .quad .TOC.-.Lfunc_gep2
94 caller:
95 .Lfunc_gep2:
96 ld 2, .Lfunc_toc2-.Lfunc_gep2(12)
97 add 2, 2, 12
98 .Lfunc_lep2:
99 .localentry caller, .Lfunc_lep2-.Lfunc_gep2
100 bl callee
104 # CHECK-LABEL: <caller_far>:
105 # CHECK: ld 2, -8(12)
106 # CHECK-NEXT: add 2, 2, 12
107 # CHECK-NEXT: bl 0x520020020
108 # CHECK-NEXT: ld 2, 24(1)
109 # CHECK-NEXT: blr
110 # CHECK-LABEL: <__toc_save_callee>:
111 # CHECK: std 2, 24(1)
112 # CHECK-NEXT: addis 12, 2, 0
113 # CHECK-NEXT: ld 12, -32760(12)
114 # CHECK-NEXT: mtctr 12
115 # CHECK-NEXT: bctr
116 .section .text_caller_far, "ax", %progbits
117 .Lfunc_toc3:
118 .quad .TOC.-.Lfunc_gep3
119 caller_far:
120 .Lfunc_gep3:
121 ld 2, .Lfunc_toc3-.Lfunc_gep3(12)
122 add 2, 2, 12
123 .Lfunc_lep3:
124 .localentry caller, .Lfunc_lep3-.Lfunc_gep3
125 bl callee