[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / ppc64-toc-relax-jumptable.s
blobf95e6d0d4c733db4d6884e0713b5d05fca0d0941
1 # REQUIRES: ppc
2 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
3 # RUN: ld.lld %t.o -o %t
4 # RUN: llvm-readelf -S %t | FileCheck --check-prefixes=SECTIONS %s
5 # RUN: llvm-readelf -x .toc %t | FileCheck --check-prefixes=HEX-LE %s
6 # RUN: llvm-objdump -d %t | FileCheck --check-prefixes=CHECK %s
8 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
9 # RUN: ld.lld %t.o -o %t
10 # RUN: llvm-readelf -S %t | FileCheck --check-prefixes=SECTIONS %s
11 # RUN: llvm-readelf -x .toc %t | FileCheck --check-prefixes=HEX-BE %s
12 # RUN: llvm-objdump -d %t | FileCheck --check-prefixes=CHECK %s
14 # .LJT is a local symbol (non-preemptable).
15 # Test we can perform the toc-indirect to toc-relative relaxation.
17 # SECTIONS: .rodata PROGBITS 00000000100001c8
19 # HEX-LE: section '.toc':
20 # HEX-LE-NEXT: 10020228 c8010010 00000000
22 # HEX-BE: section '.toc':
23 # HEX-BE-NEXT: 10020228 00000000 100001c8
25 # CHECK-LABEL: _start
26 # CHECK: clrldi 3, 3, 62
27 # CHECK-NEXT: addis 4, 2, -3
28 # CHECK-NEXT: addi 4, 4, 32680
29 # CHECK-NEXT: sldi 3, 3, 2
31 .text
32 .global _start
33 .type _start, @function
34 _start:
35 .Lstart_gep:
36 addis 2, 12, .TOC.-.Lstart_gep@ha
37 addi 2, 2, .TOC.-.Lstart_gep@l
38 .Lstart_lep:
39 .localentry _start, .Lstart_lep-.Lstart_gep
40 rldicl 3, 3, 0, 62
41 addis 4, 2, .LJTI_TE@toc@ha
42 ld 4, .LJTI_TE@toc@l(4)
43 sldi 3, 3, 2
44 lwax 3, 3, 4
45 add 3, 3, 4
46 mtctr 3
47 bctr
49 .LBB1:
50 li 3, 0
51 blr
52 .LBB2:
53 li 3, 10
54 blr
55 .LBB3:
56 li 3, 55
57 blr
58 .LBB4:
59 li 3, 255
60 blr
62 .section .rodata,"a",@progbits
63 .p2align 2
64 .LJT:
65 .long .LBB1-.LJT
66 .long .LBB2-.LJT
67 .long .LBB3-.LJT
68 .long .LBB4-.LJT
70 .section .toc,"aw",@progbits
71 # TOC entry for the jumptable address.
72 .LJTI_TE:
73 .tc .LJT[TC],.LJT