Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / X86 / align-branch-basic.s
bloba5a1d07e566e96bbf2ef76b6f9902bf64350865d
1 # RUN: llvm-mc -filetype=obj -triple x86_64 --x86-align-branch-boundary=32 --x86-align-branch=call+jmp+indirect+ret+jcc %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s
3 # These tests are checking the basic cases for each instructions, and a
4 # bit of the alignment checking logic itself. Fused instruction cases are
5 # excluded, as are details of argument parsing.
7 # instruction sizes for reference:
8 # callq is 5 bytes long
9 # int3 is 1 byte
10 # jmp <near-label> is 2 bytes
11 # jmp <far-label> is 5 bytes
12 # ret N is 2 bytes
14 # Next couple tests are checking the edge cases on the alignment computation
16 .text
17 # CHECK: <test1>:
18 # CHECK: 20: callq
19 .globl test1
20 .p2align 5
21 test1:
22 .rept 29
23 int3
24 .endr
25 callq bar
27 # CHECK: <test2>:
28 # CHECK: 60: callq
29 .globl test2
30 .p2align 5
31 test2:
32 .rept 31
33 int3
34 .endr
35 callq bar
37 # CHECK: <test3>:
38 # CHECK: a0: callq
39 .globl test3
40 .p2align 5
41 test3:
42 .rept 27
43 int3
44 .endr
45 callq bar
47 # next couple check instruction type coverage
49 # CHECK: <test_jmp>:
50 # CHECK: e0: jmp
51 .globl test_jmp
52 .p2align 5
53 test_jmp:
54 .rept 31
55 int3
56 .endr
57 jmp bar
59 # CHECK: <test_ret>:
60 # CHECK: 120: retq
61 .globl test_ret
62 .p2align 5
63 test_ret:
64 .rept 31
65 int3
66 .endr
67 retq $0
69 # check a case with a relaxable instruction
71 # CHECK: <test_jmp_far>:
72 # CHECK: 160: jmp
73 .globl test_jmp_far
74 .p2align 5
75 test_jmp_far:
76 .rept 31
77 int3
78 .endr
79 jmp baz
81 # CHECK: <test_jcc>:
82 # CHECK: 1a0: jne
83 .globl test_jcc
84 .p2align 5
85 test_jcc:
86 .rept 31
87 int3
88 .endr
89 jne bar
91 # CHECK: <test_indirect>:
92 # CHECK: 1e0: jmp
93 .globl test_indirect
94 .p2align 5
95 test_indirect:
96 .rept 31
97 int3
98 .endr
99 jmpq *(%rax)
101 .p2align 4
102 .type bar,@function
103 bar:
104 retq
106 # This case looks really tempting to pad, but doing so for the call causes
107 # the jmp to be misaligned.
108 # CHECK: <test_pad_via_relax_neg1>:
109 # CHECK: 200: int3
110 # CHECK: 21a: testq
111 # CHECK: 21d: jne
112 # CHECK: 21f: nop
113 # CHECK: 220: callq
114 .global test_pad_via_relax_neg1
115 .p2align 5
116 test_pad_via_relax_neg1:
117 .rept 26
118 int3
119 .endr
120 testq %rax, %rax
121 jnz bar
122 callq bar
124 # Same as previous, but without fusion
125 # CHECK: <test_pad_via_relax_neg2>:
126 # CHECK: 240: int3
127 # CHECK: 25d: jmp
128 # CHECK: 25f: nop
129 # CHECK: 260: callq
130 .global test_pad_via_relax_neg2
131 .p2align 5
132 test_pad_via_relax_neg2:
133 .rept 29
134 int3
135 .endr
136 jmp bar2
137 callq bar2
139 bar2:
141 .section "unknown"
142 .p2align 4
143 .type baz,@function
144 baz:
145 retq