Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / arm-thunk-re-add.s
blob7505ec045fff0c9b1c4b13a9b1de51669c2b49e0
1 // REQUIRES: arm
2 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
3 // RUN: ld.lld %t --shared -o %t.so
4 // The output file is large, most of it zeroes. We dissassemble only the
5 // parts we need to speed up the test and avoid a large output file
6 // RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1000004 --stop-address=0x100001c | FileCheck --check-prefix=CHECK1 %s
7 // RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1100008 --stop-address=0x1100022 | FileCheck --check-prefix=CHECK2 %s
8 // RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1100020 --stop-address=0x1100064 --triple=armv7a-linux-gnueabihf | FileCheck --check-prefix=CHECK3 %s
10 /// A branch to a Thunk that we create on pass N, can drift out of range if
11 /// other Thunks are added in between. In this case we must create a new Thunk
12 /// for the branch that is in range. We also need to make sure that if the
13 /// destination of the Thunk is in the PLT the new Thunk also targets the PLT
14 .syntax unified
15 .thumb
17 .macro FUNCTION suff
18 .section .text.\suff\(), "ax", %progbits
19 .thumb
20 .balign 0x80000
21 .globl tfunc\suff\()
22 .type tfunc\suff\(), %function
23 tfunc\suff\():
24 bx lr
25 .endm
27 .globl imported
28 .type imported, %function
29 .globl imported2
30 .type imported2, %function
31 .globl imported3
32 .type imported3, %function
33 .globl imported4
34 .type imported4, %function
35 FUNCTION 00
36 FUNCTION 01
37 FUNCTION 02
38 FUNCTION 03
39 FUNCTION 04
40 FUNCTION 05
41 FUNCTION 06
42 FUNCTION 07
43 FUNCTION 08
44 FUNCTION 09
45 FUNCTION 10
46 FUNCTION 11
47 FUNCTION 12
48 FUNCTION 13
49 FUNCTION 14
50 FUNCTION 15
51 FUNCTION 16
52 FUNCTION 17
53 FUNCTION 18
54 FUNCTION 19
55 FUNCTION 20
56 FUNCTION 21
57 FUNCTION 22
58 FUNCTION 23
59 FUNCTION 24
60 FUNCTION 25
61 FUNCTION 26
62 FUNCTION 27
63 FUNCTION 28
64 FUNCTION 29
65 FUNCTION 30
66 FUNCTION 31
67 /// Precreated Thunk Pool goes here
68 // CHECK1: <__ThumbV7PILongThunk_imported>:
69 // CHECK1-NEXT: 1000004: f240 0c30 movw r12, #48
70 // CHECK1-NEXT: 1000008: f2c0 0c10 movt r12, #16
71 // CHECK1-NEXT: 100000c: 44fc add r12, pc
72 // CHECK1-NEXT: 100000e: 4760 bx r12
73 // CHECK1: <__ThumbV7PILongThunk_imported2>:
74 // CHECK1-NEXT: 1000010: f240 0c34 movw r12, #52
75 // CHECK1-NEXT: 1000014: f2c0 0c10 movt r12, #16
76 // CHECK1-NEXT: 1000018: 44fc add r12, pc
77 // CHECK1-NEXT: 100001a: 4760 bx r12
79 .section .text.32, "ax", %progbits
80 .space 0x80000
81 .section .text.33, "ax", %progbits
82 .space 0x80000 - 0x14
83 .section .text.34, "ax", %progbits
84 /// Need a Thunk to the PLT entry, can use precreated ThunkSection
85 .globl callers
86 .type callers, %function
87 callers:
88 b.w imported
89 beq.w imported
90 b.w imported2
91 // CHECK2: <__ThumbV7PILongThunk_imported>:
92 // CHECK2-NEXT: 1100008: f240 0c2c movw r12, #44
93 // CHECK2-NEXT: 110000c: f2c0 0c00 movt r12, #0
94 // CHECK2-NEXT: 1100010: 44fc add r12, pc
95 // CHECK2-NEXT: 1100012: 4760 bx r12
96 // CHECK2: <callers>:
97 // CHECK2-NEXT: 1100014: f6ff bff6 b.w 0x1000004 <__ThumbV7PILongThunk_imported>
98 // CHECK2-NEXT: 1100018: f43f aff6 beq.w 0x1100008 <__ThumbV7PILongThunk_imported>
99 // CHECK2-NEXT: 110001c: f6ff bff8 b.w 0x1000010 <__ThumbV7PILongThunk_imported2>
101 // CHECK3: Disassembly of section .plt:
102 // CHECK3-EMPTY:
103 // CHECK3-NEXT: <.plt>:
104 // CHECK3-NEXT: 1100020: e52de004 str lr, [sp, #-4]!
105 // CHECK3-NEXT: 1100024: e28fe600 add lr, pc, #0, #12
106 // CHECK3-NEXT: 1100028: e28eea20 add lr, lr, #32
107 // CHECK3-NEXT: 110002c: e5bef094 ldr pc, [lr, #148]!
108 // CHECK3-NEXT: 1100030: d4 d4 d4 d4 .word 0xd4d4d4d4
109 // CHECK3-NEXT: 1100034: d4 d4 d4 d4 .word 0xd4d4d4d4
110 // CHECK3-NEXT: 1100038: d4 d4 d4 d4 .word 0xd4d4d4d4
111 // CHECK3-NEXT: 110003c: d4 d4 d4 d4 .word 0xd4d4d4d4
112 // CHECK3-NEXT: 1100040: e28fc600 add r12, pc, #0, #12
113 // CHECK3-NEXT: 1100044: e28cca20 add r12, r12, #32
114 // CHECK3-NEXT: 1100048: e5bcf07c ldr pc, [r12, #124]!
115 // CHECK3-NEXT: 110004c: d4 d4 d4 d4 .word 0xd4d4d4d4
116 // CHECK3-NEXT: 1100050: e28fc600 add r12, pc, #0, #12
117 // CHECK3-NEXT: 1100054: e28cca20 add r12, r12, #32
118 // CHECK3-NEXT: 1100058: e5bcf070 ldr pc, [r12, #112]!
119 // CHECK3-NEXT: 110005c: d4 d4 d4 d4 .word 0xd4d4d4d4
121 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7aeb-none-linux-gnueabi -mcpu=cortex-a8 %s -o %t
122 // RUN: ld.lld %t --shared -o %t.so
123 // The output file is large, most of it zeroes. We dissassemble only the
124 // parts we need to speed up the test and avoid a large output file
125 // RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1000004 --stop-address=0x100001c | FileCheck --check-prefix=CHECK1 %s
126 // RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1100008 --stop-address=0x1100022 | FileCheck --check-prefix=CHECK2 %s
127 // RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1100020 --stop-address=0x1100064 --triple=armv7aeb-linux-gnueabihf | FileCheck --check-prefix=CHECK3 %s
129 // RUN: ld.lld --be8 %t --shared -o %t.so
130 // The output file is large, most of it zeroes. We dissassemble only the
131 // parts we need to speed up the test and avoid a large output file
132 // RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1000004 --stop-address=0x100001c | FileCheck --check-prefix=CHECK1 %s
133 // RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1100008 --stop-address=0x1100022 | FileCheck --check-prefix=CHECK2 %s
134 // RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1100020 --stop-address=0x1100064 --triple=armv7aeb-linux-gnueabihf | FileCheck --check-prefix=CHECK3 %s