Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / arm-thunk-linkerscript-large.s
blob9d97375992de311dedd9b4436b9f9c764daa5e88
1 // REQUIRES: arm
2 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
3 // RUN: echo "SECTIONS { \
4 // RUN: .text 0x100000 : { *(.text) } \
5 // RUN: .textl : { *(.text_l0*) *(.text_l1*) *(.text_l2*) *(.text_l3*) } \
6 // RUN: .texth : { *(.text_h0*) *(.text_h1*) *(.text_h2*) *(.text_h3*) } \
7 // RUN: }" > %t.script
8 // RUN: ld.lld --script %t.script %t -o %t2
9 // The output file is large, most of it zeroes. We dissassemble only the
10 // parts we need to speed up the test and avoid a large output file
11 // RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x100000 --stop-address=0x100012 | FileCheck --check-prefix=CHECK1 %s
12 // RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x200000 --stop-address=0x200008 | FileCheck --check-prefix=CHECK2 %s
13 // RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0xb00004 --stop-address=0xb0000e | FileCheck --check-prefix=CHECK3 %s
14 // RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x2100000 --stop-address=0x210001a | FileCheck --check-prefix=CHECK4 %s
15 // RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x2200000 --stop-address=0x220000e | FileCheck --check-prefix=CHECK5 %s
16 // RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x4100000 --stop-address=0x4100020 | FileCheck --check-prefix=CHECK6 %s
18 // Test the range extensions in a linker script where there are several
19 // OutputSections requiring range extension Thunks. We should be able to reuse
20 // Thunks between OutputSections but our placement of new Thunks is done on a
21 // per OutputSection basis
22 .syntax unified
24 // Define a function that we can match with .text_l* aligned on a megabyte
25 // boundary
26 .macro FUNCTIONL suff
27 .section .text_l\suff\(), "ax", %progbits
28 .thumb
29 .balign 0x100000
30 .globl tfuncl\suff\()
31 .type tfuncl\suff\(), %function
32 tfuncl\suff\():
33 bx lr
34 .endm
36 // Define a function that we can match with .text_h* aligned on a megabyte
37 // boundary
38 .macro FUNCTIONH suff
39 .section .text_h\suff\(), "ax", %progbits
40 .thumb
41 .balign 0x100000
42 .globl tfunch\suff\()
43 .type tfunch\suff\(), %function
44 tfunch\suff\():
45 bx lr
46 .endm
48 .section .text, "ax", %progbits
49 .thumb
50 .globl _start
51 _start:
52 bl tfuncl00
53 // Expect a range extension thunk in .text OutputSection
54 bl tfunch31
55 // CHECK1: Disassembly of section .text:
56 // CHECK1-EMPTY:
57 // CHECK1-NEXT: <_start>:
58 // CHECK1-NEXT: 100000: f0ff fffe bl 0x200000 <tfuncl00>
59 // CHECK1-NEXT: 100004: f000 f800 bl 0x100008 <__Thumbv7ABSLongThunk_tfunch31>
60 // CHECK1: <__Thumbv7ABSLongThunk_tfunch31>:
61 // CHECK1-NEXT: 100008: f240 0c01 movw r12, #1
62 // CHECK1-NEXT: 10000c: f2c0 4c10 movt r12, #1040
63 // CHECK1-NEXT: 100010: 4760 bx r12
64 FUNCTIONL 00
65 // Create a range extension thunk in .textl
66 bl tfuncl24
67 // We can reuse existing thunk in .text
68 bl tfunch31
69 // CHECK2: Disassembly of section .textl:
70 // CHECK2-EMPTY:
71 // CHECK2-NEXT: <tfuncl00>:
72 // CHECK2-NEXT: 200000: 4770 bx lr
73 // CHECK2-NEXT: 200002: f0ff dfff bl 0xb00004 <__Thumbv7ABSLongThunk_tfuncl24>
74 // CHECK2-NEXT: 200006: f6ff ffff bl 0x100008 <__Thumbv7ABSLongThunk_tfunch31>
75 FUNCTIONL 01
76 FUNCTIONL 02
77 FUNCTIONL 03
78 FUNCTIONL 04
79 FUNCTIONL 05
80 FUNCTIONL 06
81 FUNCTIONL 07
82 FUNCTIONL 08
83 FUNCTIONL 09
84 // CHECK3: <__Thumbv7ABSLongThunk_tfuncl24>:
85 // CHECK3-NEXT: b00004: f2ff 97fc b.w 0x1a00000 <tfuncl24>
86 FUNCTIONL 10
87 FUNCTIONL 11
88 FUNCTIONL 12
89 FUNCTIONL 13
90 FUNCTIONL 14
91 FUNCTIONL 15
92 FUNCTIONL 16
93 FUNCTIONL 17
94 FUNCTIONL 18
95 FUNCTIONL 19
96 FUNCTIONL 20
97 FUNCTIONL 21
98 FUNCTIONL 22
99 FUNCTIONL 23
100 FUNCTIONL 24
101 FUNCTIONL 25
102 FUNCTIONL 26
103 FUNCTIONL 27
104 FUNCTIONL 28
105 FUNCTIONL 29
106 FUNCTIONL 30
107 FUNCTIONL 31
108 // Create range extension thunks in .textl
109 bl tfuncl00
110 bl tfuncl24
111 // Shouldn't need a thunk
112 bl tfunch00
113 // CHECK4: 2100002: f000 f805 bl 0x2100010 <__Thumbv7ABSLongThunk_tfuncl00>
114 // CHECK4-NEXT: 2100006: f4ff f7fb bl 0x1a00000 <tfuncl24>
115 // CHECK4-NEXT: 210000a: f0ff fff9 bl 0x2200000 <tfunch00>
116 // CHECK4: <__Thumbv7ABSLongThunk_tfuncl00>:
117 // CHECK4-NEXT: 2100010: f240 0c01 movw r12, #1
118 // CHECK4-NEXT: 2100014: f2c0 0c20 movt r12, #32
119 // CHECK4-NEXT: 2100018: 4760 bx r12
120 FUNCTIONH 00
121 // Can reuse existing thunks in .textl
122 bl tfuncl00
123 bl tfuncl24
124 // Shouldn't need a thunk
125 bl tfuncl31
126 // CHECK5: Disassembly of section .texth:
127 // CHECK5-EMPTY:
128 // CHECK5-NEXT: <tfunch00>:
129 // CHECK5-NEXT: 2200000: 4770 bx lr
130 // CHECK5-NEXT: 2200002: f700 f805 bl 0x2100010 <__Thumbv7ABSLongThunk_tfuncl00>
131 // CHECK5-NEXT: 2200006: f7ff dffb bl 0x1a00000 <tfuncl24>
132 // CHECK5-NEXT: 220000a: f6ff fff9 bl 0x2100000 <tfuncl31>
133 FUNCTIONH 01
134 FUNCTIONH 02
135 FUNCTIONH 03
136 FUNCTIONH 04
137 FUNCTIONH 05
138 FUNCTIONH 06
139 FUNCTIONH 07
140 FUNCTIONH 08
141 FUNCTIONH 09
142 FUNCTIONH 10
143 FUNCTIONH 11
144 FUNCTIONH 12
145 FUNCTIONH 13
146 FUNCTIONH 14
147 FUNCTIONH 15
148 FUNCTIONH 16
149 FUNCTIONH 17
150 FUNCTIONH 18
151 FUNCTIONH 19
152 FUNCTIONH 20
153 FUNCTIONH 21
154 FUNCTIONH 22
155 FUNCTIONH 23
156 FUNCTIONH 24
157 FUNCTIONH 25
158 FUNCTIONH 26
159 FUNCTIONH 27
160 FUNCTIONH 28
161 FUNCTIONH 29
162 FUNCTIONH 30
163 FUNCTIONH 31
164 // expect Thunks in .texth
165 bl tfuncl00
166 bl tfunch00
167 // CHECK6: <tfunch31>:
168 // CHECK6-NEXT: 4100000: 4770 bx lr
169 // CHECK6-NEXT: 4100002: f000 f803 bl 0x410000c <__Thumbv7ABSLongThunk_tfuncl00>
170 // CHECK6-NEXT: 4100006: f000 f806 bl 0x4100016 <__Thumbv7ABSLongThunk_tfunch00>
171 // CHECK6: <__Thumbv7ABSLongThunk_tfuncl00>:
172 // CHECK6-NEXT: 410000c: f240 0c01 movw r12, #1
173 // CHECK6-NEXT: 4100010: f2c0 0c20 movt r12, #32
174 // CHECK6-NEXT: 4100014: 4760 bx r12
175 // CHECK6: <__Thumbv7ABSLongThunk_tfunch00>:
176 // CHECK6-NEXT: 4100016: f240 0c01 movw r12, #1
177 // CHECK6-NEXT: 410001a: f2c0 2c20 movt r12, #544
178 // CHECK6-NEXT: 410001e: 4760 bx r12