• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu -x86-pad-max-prefix-size=0 %s | llvm-objdump -d --section=.text - | FileCheck %s
2
3# This test exercises only the padding via relaxation logic.  The  interaction
4# etween prefix padding and relaxation logic can be seen in align-via-padding.s
5
6  .file "test.c"
7  .text
8  .section  .text
9  # Demonstrate that we can relax instructions to provide padding, not
10  # just insert nops.  jmps are being used for ease of demonstration.
11  # CHECK: .text
12  # CHECK: 0: eb 1f                         jmp 0x21 <foo>
13  # CHECK: 2: e9 1a 00 00 00                jmp 0x21 <foo>
14  # CHECK: 7: e9 15 00 00 00                jmp 0x21 <foo>
15  # CHECK: c: e9 10 00 00 00                jmp 0x21 <foo>
16  # CHECK: 11: e9 0b 00 00 00               jmp 0x21 <foo>
17  # CHECK: 16: e9 06 00 00 00               jmp 0x21 <foo>
18  # CHECK: 1b: e9 01 00 00 00               jmp 0x21 <foo>
19  # CHECK: 20: cc                           int3
20  .p2align 4
21  jmp foo
22  jmp foo
23  jmp foo
24  jmp foo
25  jmp foo
26  jmp foo
27  jmp foo
28  .p2align 5
29  int3
30foo:
31  ret
32
33  # Check that we're not shifting aroudn the offsets of labels - doing
34  # that would require a further round of relaxation
35  # CHECK: <bar>:
36  # CHECK: 22: eb fe                          jmp 0x22 <bar>
37  # CHECK: 24: 66 66 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:(%rax,%rax)
38  # CHECK: 30: 0f 0b                          ud2
39
40bar:
41  jmp bar
42nobypass:
43  .p2align 4
44  ud2
45
46
47  # Canonical toy loop to show benefit - we can align the loop header with
48  # fewer nops by relaxing the branch, even though we don't need to
49  # CHECK: <loop_preheader>:
50  # CHECK: 45: 48 85 c0                       testq %rax, %rax
51  # CHECK: 48: 0f 8e 22 00 00 00              jle 0x70 <loop_exit>
52  # CHECK: 4e: 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:(%rax,%rax)
53  # CHECK: 5d: 0f 1f 00                       nopl (%rax)
54  # CHECK: <loop_header>:
55  # CHECK: 60: 48 83 e8 01                    subq $1, %rax
56  # CHECK: 64: 48 85 c0                       testq %rax, %rax
57  # CHECK: 67: 7e 07                          jle 0x70 <loop_exit>
58  # CHECK: 69: e9 f2 ff ff ff                 jmp 0x60 <loop_header>
59  # CHECK: 6e: 66 90                          nop
60  # CHECK: <loop_exit>:
61  # CHECK: 70: c3                             retq
62  .p2align 5
63  .skip 5
64loop_preheader:
65  testq %rax, %rax
66  jle loop_exit
67  .p2align 5
68loop_header:
69  subq $1, %rax
70  testq %rax, %rax
71  jle loop_exit
72  jmp loop_header
73  .p2align 4
74loop_exit:
75  ret
76