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 2 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. 6 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 13 14 # Next couple tests are checking the edge cases on the alignment computation 15 16 .text 17 # CHECK: <test1>: 18 # CHECK: 20: callq 19 .globl test1 20 .p2align 5 21test1: 22 .rept 29 23 int3 24 .endr 25 callq bar 26 27 # CHECK: <test2>: 28 # CHECK: 60: callq 29 .globl test2 30 .p2align 5 31test2: 32 .rept 31 33 int3 34 .endr 35 callq bar 36 37 # CHECK: <test3>: 38 # CHECK: a0: callq 39 .globl test3 40 .p2align 5 41test3: 42 .rept 27 43 int3 44 .endr 45 callq bar 46 47 # next couple check instruction type coverage 48 49 # CHECK: <test_jmp>: 50 # CHECK: e0: jmp 51 .globl test_jmp 52 .p2align 5 53test_jmp: 54 .rept 31 55 int3 56 .endr 57 jmp bar 58 59 # CHECK: <test_ret>: 60 # CHECK: 120: retq 61 .globl test_ret 62 .p2align 5 63test_ret: 64 .rept 31 65 int3 66 .endr 67 retq $0 68 69 # check a case with a relaxable instruction 70 71 # CHECK: <test_jmp_far>: 72 # CHECK: 160: jmp 73 .globl test_jmp_far 74 .p2align 5 75test_jmp_far: 76 .rept 31 77 int3 78 .endr 79 jmp baz 80 81 # CHECK: <test_jcc>: 82 # CHECK: 1a0: jne 83 .globl test_jcc 84 .p2align 5 85test_jcc: 86 .rept 31 87 int3 88 .endr 89 jne bar 90 91 # CHECK: <test_indirect>: 92 # CHECK: 1e0: jmp 93 .globl test_indirect 94 .p2align 5 95test_indirect: 96 .rept 31 97 int3 98 .endr 99 jmpq *(%rax) 100 101 .p2align 4 102 .type bar,@function 103bar: 104 retq 105 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 116test_pad_via_relax_neg1: 117 .rept 26 118 int3 119 .endr 120 testq %rax, %rax 121 jnz bar 122 callq bar 123 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 132test_pad_via_relax_neg2: 133 .rept 29 134 int3 135 .endr 136 jmp bar2 137 callq bar2 138 139bar2: 140 141 .section "unknown" 142 .p2align 4 143 .type baz,@function 144baz: 145 retq 146