Skip to content

Commit 79d0211

Browse files
committed
[MC] Add test that requires multiple relaxation steps
This can catch the code size regression due to the reverted be5a845 ("[MC] Compute fragment offsets eagerly").
1 parent deb6b45 commit 79d0211

File tree

1 file changed

+398
-0
lines changed

1 file changed

+398
-0
lines changed

llvm/test/MC/ELF/relax-branch.s

Lines changed: 398 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,398 @@
1+
## A larger branch relaxation test that requires multiple relaxation steps.
2+
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
3+
# RUN: llvm-objdump -d %t | FileCheck %s
4+
5+
## Regression test that we use jump short instead of jump near
6+
## (see the reverted be5a845e4c29aadb513ae6e5e2879dccf37efdbb).
7+
# CHECK: 4a9: eb 00 jmp 0x4ab
8+
# CHECK: 5a3: eb 00 jmp 0x5a5
9+
# CHECK-NEXT: 5a5: eb 00 jmp 0x5a7
10+
# CHECK-NEXT: 5a7: eb 00 jmp 0x5a9
11+
# CHECK-NEXT: 5a9: eb 00 jmp 0x5ab
12+
# CHECK-NEXT: 5ab: e9 fb fe ff ff jmp 0x4ab
13+
# CHECK-NEXT: 5b0: eb 00 jmp 0x5b2
14+
15+
pushq %rbp
16+
movq %rsp, %rbp
17+
movq %rcx, (%rbp)
18+
movq %r8, (%rbp)
19+
movl $0, (%rbp)
20+
movl $0, (%rbp)
21+
movl $0, (%rbp)
22+
cmpq $0, (%rbp)
23+
je .LBB0_2
24+
movl $0, (%rbp)
25+
jmp .LBB0_30
26+
.LBB0_2:
27+
jmp .LBB0_3
28+
.LBB0_3:
29+
movq (%rbp), %rax
30+
movsbl (%rax), %ecx
31+
xorl %eax, %eax
32+
cmpl %ecx, %eax
33+
jne .LBB0_29
34+
jmp .LBB0_5
35+
.LBB0_5:
36+
movb $0, %al
37+
callq sqlite3_stepPLT
38+
movl %eax, (%rbp)
39+
cmpq $0, (%rbp)
40+
je .LBB0_23
41+
movl $100, %eax
42+
cmpl (%rbp), %eax
43+
sete %al
44+
andb $1, %al
45+
movzbl %al, %eax
46+
cmpl (%rbp), %eax
47+
jne .LBB0_23
48+
cmpl $0, (%rbp)
49+
je .LBB0_23
50+
movq (%rbp), %rax
51+
movl (%rax), %eax
52+
andl $256, %eax
53+
cmpl $0, %eax
54+
je .LBB0_23
55+
cmpl $0, (%rbp)
56+
je .LBB0_22
57+
movl $0, (%rbp)
58+
.LBB0_11:
59+
cmpl $0, (%rbp)
60+
je .LBB0_13
61+
movl (%rbp), %esi
62+
xorl %edi, %edi
63+
movb $0, %al
64+
callq sqlite3_free_tablePLT
65+
jmp .LBB0_11
66+
.LBB0_13:
67+
movq (%rbp), %rax
68+
movslq (%rbp), %rcx
69+
cmpb $0, (%rax,%rcx)
70+
je .LBB0_15
71+
movq (%rbp), %rax
72+
movb $1, 8(%rax)
73+
.LBB0_15:
74+
movq (%rbp), %rax
75+
movslq (%rbp), %rcx
76+
addq %rcx, %rax
77+
movq %rax, (%rip)
78+
movl $0, (%rbp)
79+
.LBB0_16:
80+
movl (%rbp), %eax
81+
cmpl (%rbp), %eax
82+
jge .LBB0_21
83+
movl $0, (%rbp)
84+
movl $0, (%rbp)
85+
movq (%rbp), %rdi
86+
movb $0, %al
87+
callq sqlite3_free_tablePLT
88+
movq (%rip), %rax
89+
movslq (%rbp), %rcx
90+
movl $5, %edx
91+
cmpq %rdx, (%rax,%rcx,)
92+
je .LBB0_19
93+
movq (%rbp), %rax
94+
movb $1, 8(%rax)
95+
jmp .LBB0_30
96+
.LBB0_19:
97+
jmp .LBB0_20
98+
.LBB0_20:
99+
movl (%rbp), %eax
100+
addl $1, %eax
101+
movl %eax, (%rbp)
102+
jmp .LBB0_16
103+
.LBB0_21:
104+
jmp .LBB0_22
105+
.LBB0_22:
106+
jmp .LBB0_23
107+
.LBB0_23:
108+
cmpl $0, (%rbp)
109+
je .LBB0_27
110+
movb $0, %al
111+
callq sqlite3_stepPLT
112+
movl %eax, (%rbp)
113+
movl $0, (%rbp)
114+
cmpl $0, (%rbp)
115+
je .LBB0_26
116+
jmp .LBB0_28
117+
.LBB0_26:
118+
jmp .LBB0_27
119+
.LBB0_27:
120+
jmp .LBB0_5
121+
.LBB0_28:
122+
jmp .LBB0_3
123+
.LBB0_29:
124+
jmp .LBB0_30
125+
.LBB0_30:
126+
movl (%rbp), %eax
127+
addq $96, %rsp
128+
popq %rbp
129+
retq
130+
.p2align 4, 0x90
131+
movq %rsp, %rbp
132+
subq $48, %rsp
133+
movq %rdi, (%rbp)
134+
movl %esi, (%rbp)
135+
movl %edx, (%rbp)
136+
cmpq $0, sqlite3_get_table_res_00
137+
movq (%rbp), %rax
138+
jmp .LBB1_8
139+
movq $0, (%rbp)
140+
movq (%rbp), %rdi
141+
leaq sqlite3_get_table_zSql0, %rsi
142+
leaq sqlite3_get_table_cb0, %rdx
143+
leaq sqlite3_get_table_res0, %rcx
144+
leaq (%rip), %r8
145+
callq sqlite3_exec
146+
movl %eax, (%rip)
147+
movslq (%rbp), %rax
148+
movq %rax, (%rbp)
149+
movl (%rip), %eax
150+
andl $5, %eax
151+
cmpl $0, %eax
152+
je .LBB1_4
153+
movl (%rip), %ecx
154+
movq (%rbp), %rax
155+
movl %ecx, (%rax)
156+
movl (rip), %eax
157+
movl %eax, (%rbp)
158+
jmp .LBB1_8
159+
.LBB1_4:
160+
movsbl (%rip), %edi
161+
movb $0, %al
162+
callq sqlite3_free_tablePLT
163+
cmpl $0, (%rip)
164+
je .LBB1_6
165+
movq (%rip), %rax
166+
movsbl (%rax), %edi
167+
movb $0, %al
168+
callq sqlite3_free_tablePLT
169+
.LBB1_6:
170+
movq (rip), %rdi
171+
movslq (%rbp), %rsi
172+
shlq $0, %rsi
173+
addq $1, %rsi
174+
movb $0, %al
175+
callq sqlite3_mallocPLT
176+
movq %rax, (%rbp)
177+
cmpq $0, (%rbp)
178+
je .LBB1_8
179+
movl $1, (%rbp)
180+
.LBB1_8:
181+
movl (%rbp), %eax
182+
addq $48, %rsp
183+
.p2align 4, 0x90
184+
movq (%rbp), %rax
185+
movl 28(%rax), %eax
186+
movq (%rbp), %rcx
187+
addl 16(%rcx), %eax
188+
cmpl $0, %eax
189+
movq (%rbp), %rax
190+
movl 16(%rax), %ecx
191+
addl (%rbp), %ecx
192+
addl $1, %ecx
193+
movq (%rbp), %rax
194+
movl %ecx, 16(%rax)
195+
jmp .LBB2_14
196+
movq (%rbp), %rax
197+
cmpl $0, 20(%rax)
198+
je .LBB2_10
199+
movl $0, (%rbp)
200+
movq (%rbp), %rax
201+
movl $0, 24(%rax)
202+
.LBB2_4:
203+
movl (%rbp), %eax
204+
cmpl (%rbp), %eax
205+
jge .LBB2_7
206+
movq (%rbp), %rax
207+
movslq (%rbp), %rcx
208+
movsbl (%rax,%rcx), %esi
209+
leaq .str, %rdi
210+
movb $0, %al
211+
callq sqlite3_mprintf@PLT
212+
movq %rax, -64(%rbp)
213+
movl -56(%rbp), %eax
214+
addl $1, %eax
215+
movl %eax, -56(%rbp)
216+
jmp .LBB2_4
217+
.LBB2_7:
218+
cmpq $0, -64(%rbp)
219+
je .LBB2_9
220+
jmp .LBB2_9
221+
.LBB2_9:
222+
movq -64(%rbp), %rdx
223+
movq -48(%rbp), %rax
224+
movq (%rax), %rax
225+
movq -48(%rbp), %rsi
226+
movl 28(%rsi), %ecx
227+
movl %ecx, %edi
228+
addl $1, %edi
229+
movl %edi, 28(%rsi)
230+
movslq %ecx, %rcx
231+
movq %rdx, (%rax,%rcx,8)
232+
jmp .LBB2_13
233+
.LBB2_10:
234+
movq -48(%rbp), %rax
235+
movslq -20(%rbp), %rcx
236+
cmpq %rcx, %rax
237+
je .LBB2_12
238+
movq -48(%rbp), %rax
239+
movq 8(%rax), %rdi
240+
movb $0, %al
241+
callq sqlite3_free_table@PLT
242+
leaq .L.str, %rdi
243+
movb $0, %al
244+
callq sqlite3_mprintf@PLT
245+
movq %rax, %rcx
246+
movq -48(%rbp), %rax
247+
movq %rcx, 8(%rax)
248+
movq -48(%rbp), %rax
249+
movl $1, 32(%rax)
250+
movl $1, -4(%rbp)
251+
jmp .LBB2_15
252+
.LBB2_12:
253+
jmp .LBB2_13
254+
.LBB2_13:
255+
movl $0, -4(%rbp)
256+
jmp .LBB2_15
257+
.LBB2_14:
258+
.LBB2_15:
259+
movl -4(%rbp), %eax
260+
addq $64, %rsp
261+
popq %rbp
262+
.p2align 4, 0x90
263+
sqlite3_complete:
264+
je .LBB3_54
265+
je .LBB3_25
266+
je .LBB3_25
267+
je .LBB3_25
268+
jmp .LBB3_28
269+
movl $42, %eax
270+
cmpq %rax, -160
271+
je .LBB3_5
272+
jmp .LBB3_53
273+
.LBB3_5:
274+
jmp .LBB3_6
275+
.LBB3_6:
276+
movq -160, %rax
277+
movsbl 0, %ecx
278+
xorl %eax, %eax
279+
movb $1, %al
280+
movl $42, %ecx
281+
cmpq %rcx, -160
282+
movb %al, -340
283+
jne .LBB3_9
284+
movq -160, %rax
285+
movsbl 10, %eax
286+
cmpl $0, %eax
287+
setne %al
288+
movb %al, -340
289+
.LBB3_9:
290+
movb -340, %al
291+
movb %al, -330
292+
movb -330, %al
293+
testb $1, %al
294+
jne .LBB3_11
295+
jmp .LBB3_14
296+
.LBB3_11:
297+
movq -160, %rax
298+
movsbl 0, %eax
299+
cmpl $0, %eax
300+
jne .LBB3_13
301+
movl $0, -40
302+
jmp .LBB3_54
303+
.LBB3_13:
304+
jmp .LBB3_6
305+
.LBB3_14:
306+
jmp .LBB3_53
307+
movq -160, %rax
308+
movsbl 10, %eax
309+
cmpl $45, %eax
310+
je .LBB3_17
311+
movb $2, -170
312+
jmp .LBB3_53
313+
.LBB3_17:
314+
jmp .LBB3_18
315+
.LBB3_18:
316+
movq -160, %rax
317+
movsbl 0, %ecx
318+
xorl %eax, %eax
319+
cmpl $0, %ecx
320+
movb %al, -350
321+
jmp .LBB3_53
322+
.LBB3_25:
323+
movl $0, -40
324+
jmp .LBB3_54
325+
jmp .LBB3_53
326+
.LBB3_28:
327+
je .LBB3_52
328+
jmp .LBB3_52
329+
jmp .LBB3_31
330+
.LBB3_31:
331+
movq -160, %rax
332+
movslq -280, %rcx
333+
movsbl 0, %ecx
334+
movb -360, %al
335+
andb $1, %cl
336+
movzbl %cl, %ecx
337+
movl %ecx, -240
338+
testb $1, %al
339+
jne .LBB3_36
340+
jmp .LBB3_51
341+
.LBB3_36:
342+
movq -160, %rax
343+
movsbl 0, %eax
344+
orl $32, %eax
345+
cmpl $0, -280
346+
je .LBB3_40
347+
movq -160, %rdi
348+
leaq .L.str, %rsi
349+
movl $7, %edx
350+
movb $0, %al
351+
callq sqlite3StrNICmp@PLT
352+
cmpl $0, %eax
353+
je .LBB3_40
354+
jmp .LBB3_48
355+
.LBB3_40:
356+
cmpl $0, -280
357+
je .LBB3_43
358+
movq -160, %rdi
359+
leaq .L.str, %rsi
360+
movl $4, %edx
361+
movb $0, %al
362+
callq sqlite3StrNICmp@PLT
363+
cmpl $0, %eax
364+
je .LBB3_43
365+
movb $5, -170
366+
jmp .LBB3_47
367+
.LBB3_43:
368+
cmpl $0, -280
369+
je .LBB3_46
370+
movq -160, %rdi
371+
leaq .L.str, %rsi
372+
movl $9, %edx
373+
movb $0, %al
374+
callq sqlite3StrNICmp@PLT
375+
cmpl $0, %eax
376+
je .LBB3_46
377+
movl -280, %ecx
378+
subl $1, %ecx
379+
movq -160, %rax
380+
movslq %ecx, %rcx
381+
addq %rcx, %rax
382+
movq %rax, -160
383+
.LBB3_46:
384+
jmp .LBB3_47
385+
.LBB3_47:
386+
jmp .LBB3_48
387+
.LBB3_48:
388+
jmp .LBB3_49
389+
.LBB3_49:
390+
jmp .LBB3_50
391+
.LBB3_50:
392+
jmp .LBB3_31
393+
.LBB3_51:
394+
jmp .LBB3_52
395+
.LBB3_52:
396+
.LBB3_53:
397+
.LBB3_54:
398+
.L.str:

0 commit comments

Comments
 (0)