Commit d2b522f1 authored by Shengchen Kan's avatar Shengchen Kan
Browse files

[NFC][X86] Simplify test cases for branch align

parent 56aed614
Loading
Loading
Loading
Loading
+0 −43
Original line number Diff line number Diff line
  .text
  .globl  foo
  .p2align  4
foo:
  .rept 3
  movl  %eax, %fs:0x1
  .endr
  cmp  %rax, %rbp
  xorl %eax, %eax
  cmp  %rax, %rbp
  je  .L_2
  .rept 3
  movl  %eax, %fs:0x1
  .endr
  xorl %eax, %eax
  je  .L_2
  popq  %rbp
  je  .L_2
  .rept 3
  movl  %eax, %fs:0x1
  .endr
  xorl %eax, %eax
  jmp  .L_3
  jmp  .L_3
  jmp  .L_3
  .rept 2
  movl  %eax, %fs:0x1
  .endr
  movl  %eax, -4(%rbp)
  popq  %rbp
  cmp  %rax, %rbp
  je  .L_2
  jmp  .L_3
.L_2:
  movl  -12(%rbp), %eax
  movl  %eax, -4(%rbp)
.L_3:
  .rept 10
  movl  %esi, -1200(%rbp)
  .endr
  jmp  .L_3
  retq
+0 −27
Original line number Diff line number Diff line
  .text
  .globl  foo
  .p2align  4
foo:
  .rept 3
  movl  %eax, %fs:0x1
  .endr
  .rept 2
  movl  %esi, -12(%rbp)
  .endr
  jmp  *%rax
  .rept 3
  movl  %eax, %fs:0x1
  .endr
  movl  %esi, -12(%rbp)
  pushq  %rbp
  call *%rax
  .rept 3
  movl  %eax, %fs:0x1
  .endr
  pushq  %rbp
  call  foo
  .rept 4
  movl  %eax, %fs:0x1
  .endr
  call  *foo
+0 −38
Original line number Diff line number Diff line
# Check NOP padding is disabled before instruction that has variant symbol operand.
# RUN: llvm-mc -filetype=obj -triple i386-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=call %s | llvm-objdump -d  - | FileCheck %s

# CHECK: 00000000 <foo>:
# CHECK-COUNT-5:      : 64 a3 01 00 00 00                movl    %eax, %fs:1
# CHECK:            1e: e8 fc ff ff ff                   calll   {{.*}}
# CHECK-COUNT-4:      : 64 a3 01 00 00 00                movl    %eax, %fs:1
# CHECK:            3b: 55                               pushl   %ebp
# CHECK-NEXT:       3c: ff 91 00 00 00 00                calll   *(%ecx)
# CHECK-COUNT-4:      : 64 a3 01 00 00 00                movl    %eax, %fs:1
# CHECK:            5a: c1 e9 02                         shrl    $2, %ecx
# CHECK-NEXT:       5d: 55                               pushl   %ebp
# CHECK-NEXT:       5e: ff 10                            calll   *(%eax)
# CHECK-COUNT-5:      : 64 a3 01 00 00 00                movl    %eax, %fs:1
# CHECK-NEXT:       7e: ff 20                            jmpl    *(%eax)
  .text
  .globl  foo
  .p2align  4
foo:
  .rept 5
  movl  %eax, %fs:0x1
  .endr
  call    ___tls_get_addr@PLT
  .rept 4
  movl  %eax, %fs:0x1
  .endr
  pushl  %ebp
  call *___tls_get_addr@GOT(%ecx)
  .rept 4
  movl  %eax, %fs:0x1
  .endr
  shrl  $2, %ecx
  pushl %ebp
  call *foo@tlscall(%eax)
  .rept 5
  movl  %eax, %fs:0x1
  .endr
  jmp  *foo@tlscall(%eax)
+15 −0
Original line number Diff line number Diff line
  # RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=jmp %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s

  # Check the branch align mechanism can work in 32-bit mode.

  .text
  .rept 31
  int3
  .endr
  # CHECK:    20:          jmp
  jmp bar


  .type   bar,@function
bar:
  ret
+0 −43
Original line number Diff line number Diff line
# Check only fused conditional jumps, conditional jumps and unconditional jumps are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp %p/Inputs/align-branch-64-1.s -o %t1 && llvm-objdump -d %t1 | FileCheck %s

# Check that -x86-branches-within-32B-boundaries matches the above command line
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-branches-within-32B-boundaries %p/Inputs/align-branch-64-1.s -o %t2
# RUN: cmp %t1 %t2

# Check no branches is aligned with option --x86-align-branch-boundary=0
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=0 --x86-align-branch=fused+jcc+jmp %p/Inputs/align-branch-64-1.s | llvm-objdump -d  - > %t3
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %p/Inputs/align-branch-64-1.s | llvm-objdump -d  - > %t4
# RUN: cmp %t3 %t4

# CHECK: 0000000000000000 <foo>:
# CHECK-COUNT-3:      : 64 89 04 25 01 00 00 00          movl    %eax, %fs:1
# CHECK:            18: 48 39 c5                         cmpq    %rax, %rbp
# CHECK-NEXT:       1b: 31 c0                            xorl    %eax, %eax
# CHECK-COUNT-3:      : 90                               nop
# CHECK:            20: 48 39 c5                         cmpq    %rax, %rbp
# CHECK-NEXT:       23: 74 5d                            je      {{.*}}
# CHECK-COUNT-3:      : 64 89 04 25 01 00 00 00          movl    %eax, %fs:1
# CHECK:            3d: 31 c0                            xorl    %eax, %eax
# CHECK-NEXT:       3f: 90                               nop
# CHECK-NEXT:       40: 74 40                            je      {{.*}}
# CHECK-NEXT:       42: 5d                               popq    %rbp
# CHECK-NEXT:       43: 74 3d                            je      {{.*}}
# CHECK-COUNT-3:      : 64 89 04 25 01 00 00 00          movl    %eax, %fs:1
# CHECK:            5d: 31 c0                            xorl    %eax, %eax
# CHECK-NEXT:       5f: 90                               nop
# CHECK-NEXT:       60: eb 26                            jmp     {{.*}}
# CHECK-NEXT:       62: eb 24                            jmp     {{.*}}
# CHECK-NEXT:       64: eb 22                            jmp     {{.*}}
# CHECK-COUNT-2:      : 64 89 04 25 01 00 00 00          movl    %eax, %fs:1
# CHECK:            76: 89 45 fc                         movl    %eax, -4(%rbp)
# CHECK-NEXT:       79: 5d                               popq    %rbp
# CHECK-NEXT:       7a: 48 39 c5                         cmpq    %rax, %rbp
# CHECK-NEXT:       7d: 74 03                            je      {{.*}}
# CHECK-NEXT:       7f: 90                               nop
# CHECK-NEXT:       80: eb 06                            jmp     {{.*}}
# CHECK-NEXT:       82: 8b 45 f4                         movl    -12(%rbp), %eax
# CHECK-NEXT:       85: 89 45 fc                         movl    %eax, -4(%rbp)
# CHECK-COUNT-10:     : 89 b5 50 fb ff ff                movl    %esi, -1200(%rbp)
# CHECK:            c4: eb c2                            jmp     {{.*}}
# CHECK-NEXT:       c6: c3                               retq
Loading