Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / ppc64-long-branch.s
blobc937048e6ed80484a26fc36a17a6b33e4c5550bd
1 # REQUIRES: ppc
2 # RUN: echo 'SECTIONS { \
3 # RUN: .text_low 0x2000: { *(.text_low) } \
4 # RUN: .text_high 0x2002000 : { *(.text_high) } \
5 # RUN: }' > %t.script
7 # RUN: llvm-mc -filetype=obj -triple=ppc64le %s -o %t.o
8 # RUN: ld.lld -T %t.script %t.o -o %t
9 # RUN: llvm-readelf -S -r %t | FileCheck --check-prefix=SEC %s
10 # RUN: llvm-readelf -x .branch_lt %t | FileCheck --check-prefix=BRANCH-LE %s
11 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
12 # RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
14 # RUN: llvm-mc -filetype=obj -triple=ppc64 %s -o %t.o
15 # RUN: ld.lld -T %t.script %t.o -o %t
16 # RUN: llvm-readelf -S -r %t | FileCheck --check-prefix=SEC %s
17 # RUN: llvm-readelf -x .branch_lt %t | FileCheck --check-prefix=BRANCH-BE %s
18 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
19 # RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
21 # SEC: Name Type Address Off Size ES Flg Lk Inf Al
22 # SEC: .got PROGBITS 0000000002002040 2002040 000008 00 WA 0 0 8
23 # SEC: .branch_lt PROGBITS 0000000002002048 2002048 000018 00 WA 0 0 8
25 # SEC: There are no relocations in this file.
27 ## high@localentry (high+8), .text_high+16 and .text_low+8
28 # BRANCH-LE: 0x02002048 08200002 00000000 10200002 00000000
29 # BRANCH-LE-NEXT: 0x02002058 08200000 00000000
30 # BRANCH-BE: 0x02002048 00000000 02002008 00000000 02002010
31 # BRANCH-BE-NEXT: 0x02002058 00000000 00002008
33 # CHECK: <_start>:
34 # CHECK-NEXT: 2000: bl 0x2020
35 # CHECK-NEXT: bl 0x2020
36 # CHECK-NEXT: bl 0x2020
37 # CHECK-NEXT: bl 0x2002008
39 ## &.branch_lt[0] - .TOC. = .branch_lt - (.got+0x8000) = -32760
40 # CHECK: <__long_branch_high>:
41 # CHECK-NEXT: 2020: addis 12, 2, 0
42 # CHECK-NEXT: ld 12, -32760(12)
43 # CHECK-NEXT: mtctr 12
44 # CHECK-NEXT: bctr
46 ## &.branch_lt[1] - .TOC. = .branch_lt - (.got+0x8000) = -32752
47 # CHECK: <__long_branch_>:
48 # CHECK-NEXT: 2040: addis 12, 2, 0
49 # CHECK-NEXT: ld 12, -32752(12)
50 # CHECK-NEXT: mtctr 12
51 # CHECK-NEXT: bctr
53 .section .text_low, "ax", %progbits
54 .globl _start
55 _start:
56 bl high # Need a thunk
57 bl high # Need a thunk
58 bl high # Need a thunk
59 bl high
60 bl .text_high+16 # Need a thunk
61 blr
63 # CHECK: Disassembly of section .text_high:
64 # CHECK-EMPTY:
65 # CHECK-NEXT: <high>:
66 # CHECK-NEXT: 2002000: addis 2, 12, 1
67 # CHECK-NEXT: addi 2, 2, -32704
68 # CHECK-NEXT: bl 0x2008
69 # CHECK-NEXT: bl 0x2002020
70 # CHECK: <__long_branch_>:
71 # CHECK-NEXT: 2002020: addis 12, 2, 0
72 # CHECK-NEXT: ld 12, -32744(12)
73 # CHECK-NEXT: mtctr 12
74 # CHECK-NEXT: bctr
76 .section .text_high, "ax", %progbits
77 .globl high
78 high:
79 addis 2, 12, .TOC.-high@ha
80 addi 2, 2, .TOC.-high@l
81 .localentry high, 8
82 bl .text_low+8
83 bl .text_low+8 # Need a thunk
84 blr
86 # NM: d .TOC.
87 # NM-NEXT: t __long_branch_high
88 # NM-NEXT: t __long_branch_{{$}}
89 # NM-NEXT: t __long_branch_{{$}}
90 # NM-NEXT: T _start
91 # NM-NEXT: T high