[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / ppc64-pcrel-call-to-toc.s
blob1d3b3f73eaff4ccb93fc34e5f4cc74dbced555ef
1 # REQUIRES: ppc
2 # RUN: echo 'SECTIONS { \
3 # RUN: .text_func 0x10010000 : { *(.text_func) } \
4 # RUN: .text_callee 0x10020000 : { *(.text_callee) } \
5 # RUN: .text_caller 0x10030000 : { *(.text_caller) } \
6 # RUN: }' > %t.script
8 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
9 # RUN: ld.lld -T %t.script %t.o -o %t
10 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
11 # RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t | FileCheck %s
13 # RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.o
14 # RUN: ld.lld -T %t.script %t.o -o %t --no-power10-stubs --power10-stubs=yes
15 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
16 # RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t | FileCheck %s
18 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
19 # RUN: ld.lld -T %t.script %t.o -o %t --power10-stubs=auto --no-power10-stubs
20 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
21 # RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t \
22 # RUN: | FileCheck %s --check-prefix=CHECK-NOP10
24 ## When a function without TOC accesses a function using TOC, an r12 setup stub
25 ## is inserted
27 # SYMBOL: 1: 0000000010010000 0 NOTYPE LOCAL DEFAULT 1 func
28 # SYMBOL-NEXT: 2: 0000000010020000 0 NOTYPE LOCAL DEFAULT [<other: 0x60>] 2 callee
29 # SYMBOL: 4: 0000000010030000 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 3 caller
30 # SYMBOL: 6: 0000000010030010 32 FUNC LOCAL DEFAULT 3 __gep_setup_callee
32 # CHECK-LABEL: <func>:
33 # CHECK-NEXT: blr
35 # CHECK-LABEL: <callee>:
36 # CHECK: bl 0x10010000
37 # CHECK-NEXT: addis 4, 2, -1
38 # CHECK-NEXT: lwz 4, 32728(4)
39 # CHECK-NEXT: blr
41 # CHECK-LABEL: <caller>:
42 # CHECK-NEXT: bl 0x10030010
43 # CHECK-NEXT: blr
45 # CHECK-LABEL: <__gep_setup_callee>:
46 # CHECK-NEXT: paddi 12, 0, -65552, 1
47 # CHECK-NEXT: mtctr 12
48 # CHECK-NEXT: bctr
50 # CHECK-NOP10-LABEL: <__gep_setup_callee>:
51 # CHECK-NOP10-NEXT: mflr 0
52 # CHECK-NOP10-NEXT: bcl 20, 31, 0x10030018
53 # CHECK-NOP10-NEXT: mflr 11
54 # CHECK-NOP10-NEXT: mtlr 12
55 # CHECK-NOP10-NEXT: addis 12, 11, -1
56 # CHECK-NOP10-NEXT: addi 12, 12, -24
57 # CHECK-NOP10-NEXT: mtctr 12
58 # CHECK-NOP10-NEXT: bctr
60 .section .text_func, "ax", %progbits
61 func:
62 blr
64 .section .text_callee, "ax", %progbits
65 callee:
66 .Lfunc_gep1:
67 addis 2, 12, .TOC.-.Lfunc_gep1@ha
68 addi 2, 2, .TOC.-.Lfunc_gep1@l
69 .Lfunc_lep1:
70 .localentry callee, .Lfunc_lep1-.Lfunc_gep1
71 bl func
72 addis 4, 2, global@toc@ha
73 lwz 4, global@toc@l(4)
74 blr
76 .section .text_caller, "ax", %progbits
77 caller:
78 .localentry caller, 1
79 bl callee@notoc
80 blr
81 global:
82 .long 0
83 .size global, 4