From d2b522f173cf77f49dede3c3789895f8de6e5747 Mon Sep 17 00:00:00 2001 From: Shengchen Kan Date: Sun, 15 Mar 2020 06:09:04 +0800 Subject: [PATCH] [NFC][X86] Simplify test cases for branch align --- llvm/test/MC/X86/Inputs/align-branch-64-1.s | 43 --------- llvm/test/MC/X86/Inputs/align-branch-64-2.s | 27 ------ llvm/test/MC/X86/align-branch-32-1a.s | 38 -------- llvm/test/MC/X86/align-branch-32-work.s | 15 +++ llvm/test/MC/X86/align-branch-64-1a.s | 43 --------- llvm/test/MC/X86/align-branch-64-1b.s | 32 ------- llvm/test/MC/X86/align-branch-64-1c.s | 31 ------- llvm/test/MC/X86/align-branch-64-1d.s | 38 -------- llvm/test/MC/X86/align-branch-64-2a.s | 17 ---- llvm/test/MC/X86/align-branch-64-2b.s | 17 ---- llvm/test/MC/X86/align-branch-64-2c.s | 19 ---- llvm/test/MC/X86/align-branch-64-3a.s | 41 -------- llvm/test/MC/X86/align-branch-64-4a.s | 33 ------- llvm/test/MC/X86/align-branch-64-5a.s | 43 --------- llvm/test/MC/X86/align-branch-64-6a.s | 50 ---------- llvm/test/MC/X86/align-branch-64-align.s | 26 ++++++ ...gn-branch-64.s => align-branch-64-basic.s} | 0 ...ranch-64-7a.s => align-branch-64-bundle.s} | 0 llvm/test/MC/X86/align-branch-64-fused.s | 42 +++++++++ llvm/test/MC/X86/align-branch-64-general.s | 49 ++++++++++ llvm/test/MC/X86/align-branch-64-mixed.s | 51 ++++++++++ llvm/test/MC/X86/align-branch-64-necessary.s | 54 +++++++++++ llvm/test/MC/X86/align-branch-64-relax-all.s | 42 +++++++++ .../MC/X86/align-branch-64-section-size.s | 20 ++++ llvm/test/MC/X86/align-branch-64-single.s | 93 +++++++++++++++++++ .../X86/align-branch-boundary-default.s | 0 .../test/MC/X86/align-branch-variant-symbol.s | 57 ++++++++++++ 27 files changed, 449 insertions(+), 472 deletions(-) delete mode 100644 llvm/test/MC/X86/Inputs/align-branch-64-1.s delete mode 100644 llvm/test/MC/X86/Inputs/align-branch-64-2.s delete mode 100644 llvm/test/MC/X86/align-branch-32-1a.s create mode 100644 llvm/test/MC/X86/align-branch-32-work.s delete mode 100644 llvm/test/MC/X86/align-branch-64-1a.s delete mode 100644 llvm/test/MC/X86/align-branch-64-1b.s delete mode 100644 llvm/test/MC/X86/align-branch-64-1c.s delete mode 100644 llvm/test/MC/X86/align-branch-64-1d.s delete mode 100644 llvm/test/MC/X86/align-branch-64-2a.s delete mode 100644 llvm/test/MC/X86/align-branch-64-2b.s delete mode 100644 llvm/test/MC/X86/align-branch-64-2c.s delete mode 100644 llvm/test/MC/X86/align-branch-64-3a.s delete mode 100644 llvm/test/MC/X86/align-branch-64-4a.s delete mode 100644 llvm/test/MC/X86/align-branch-64-5a.s delete mode 100644 llvm/test/MC/X86/align-branch-64-6a.s create mode 100644 llvm/test/MC/X86/align-branch-64-align.s rename llvm/test/MC/X86/{align-branch-64.s => align-branch-64-basic.s} (100%) rename llvm/test/MC/X86/{align-branch-64-7a.s => align-branch-64-bundle.s} (100%) create mode 100644 llvm/test/MC/X86/align-branch-64-fused.s create mode 100644 llvm/test/MC/X86/align-branch-64-general.s create mode 100644 llvm/test/MC/X86/align-branch-64-mixed.s create mode 100644 llvm/test/MC/X86/align-branch-64-necessary.s create mode 100644 llvm/test/MC/X86/align-branch-64-relax-all.s create mode 100644 llvm/test/MC/X86/align-branch-64-section-size.s create mode 100644 llvm/test/MC/X86/align-branch-64-single.s rename llvm/test/{CodeGen => MC}/X86/align-branch-boundary-default.s (100%) create mode 100644 llvm/test/MC/X86/align-branch-variant-symbol.s diff --git a/llvm/test/MC/X86/Inputs/align-branch-64-1.s b/llvm/test/MC/X86/Inputs/align-branch-64-1.s deleted file mode 100644 index e5ca17621d03..000000000000 --- a/llvm/test/MC/X86/Inputs/align-branch-64-1.s +++ /dev/null @@ -1,43 +0,0 @@ - .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 - diff --git a/llvm/test/MC/X86/Inputs/align-branch-64-2.s b/llvm/test/MC/X86/Inputs/align-branch-64-2.s deleted file mode 100644 index 16b854da71e2..000000000000 --- a/llvm/test/MC/X86/Inputs/align-branch-64-2.s +++ /dev/null @@ -1,27 +0,0 @@ - .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 - diff --git a/llvm/test/MC/X86/align-branch-32-1a.s b/llvm/test/MC/X86/align-branch-32-1a.s deleted file mode 100644 index ed11539d7d23..000000000000 --- a/llvm/test/MC/X86/align-branch-32-1a.s +++ /dev/null @@ -1,38 +0,0 @@ -# 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 : -# 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) diff --git a/llvm/test/MC/X86/align-branch-32-work.s b/llvm/test/MC/X86/align-branch-32-work.s new file mode 100644 index 000000000000..44c13ef9d271 --- /dev/null +++ b/llvm/test/MC/X86/align-branch-32-work.s @@ -0,0 +1,15 @@ + # 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 diff --git a/llvm/test/MC/X86/align-branch-64-1a.s b/llvm/test/MC/X86/align-branch-64-1a.s deleted file mode 100644 index 02818b295439..000000000000 --- a/llvm/test/MC/X86/align-branch-64-1a.s +++ /dev/null @@ -1,43 +0,0 @@ -# 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 : -# 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 diff --git a/llvm/test/MC/X86/align-branch-64-1b.s b/llvm/test/MC/X86/align-branch-64-1b.s deleted file mode 100644 index 73864ba89a87..000000000000 --- a/llvm/test/MC/X86/align-branch-64-1b.s +++ /dev/null @@ -1,32 +0,0 @@ -# Check only fused conditional jumps and conditional jumps are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc %p/Inputs/align-branch-64-1.s | llvm-objdump -d - | FileCheck %s - -# CHECK: 0000000000000000 : -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 18: 48 39 c5 cmpq %rax, %rbp -# CHECK-NEXT: 1b: 31 c0 xorl %eax, %eax -# CHECK-COUNT-3: : 90 nop -# CHECK-NEXT: 20: 48 39 c5 cmpq %rax, %rbp -# CHECK-NEXT: 23: 74 5b 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 3e je {{.*}} -# CHECK-NEXT: 42: 5d popq %rbp -# CHECK-NEXT: 43: 74 3b 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: eb 25 jmp {{.*}} -# CHECK-NEXT: 61: eb 23 jmp {{.*}} -# CHECK-NEXT: 63: eb 21 jmp {{.*}} -# CHECK-COUNT-2: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 75: 89 45 fc movl %eax, -4(%rbp) -# CHECK: 78: 5d popq %rbp -# CHECK-NEXT: 79: 48 39 c5 cmpq %rax, %rbp -# CHECK-NEXT: 7c: 74 02 je {{.*}} -# CHECK-NEXT: 7e: eb 06 jmp {{.*}} -# CHECK-NEXT: 80: 8b 45 f4 movl -12(%rbp), %eax -# CHECK-NEXT: 83: 89 45 fc movl %eax, -4(%rbp) -# CHECK-COUNT-10: : 89 b5 50 fb ff ff movl %esi, -1200(%rbp) -# CHECK: c2: eb c2 jmp {{.*}} -# CHECK-NEXT: c4: c3 retq diff --git a/llvm/test/MC/X86/align-branch-64-1c.s b/llvm/test/MC/X86/align-branch-64-1c.s deleted file mode 100644 index 3207f540d208..000000000000 --- a/llvm/test/MC/X86/align-branch-64-1c.s +++ /dev/null @@ -1,31 +0,0 @@ -# Check only conditional jumps are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=jcc -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=jcc %p/Inputs/align-branch-64-1.s | llvm-objdump -d - | FileCheck %s - -# CHECK: 0000000000000000 : -# 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-NEXT: 1d: 48 39 c5 cmpq %rax, %rbp -# CHECK-NEXT: 20: 74 5b je {{.*}} -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 3a: 31 c0 xorl %eax, %eax -# CHECK-NEXT: 3c: 74 3f je {{.*}} -# CHECK-NEXT: 3e: 5d popq %rbp -# CHECK-NEXT: 3f: 90 nop -# CHECK-NEXT: 40: 74 3b je {{.*}} -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 5a: 31 c0 xorl %eax, %eax -# CHECK-NEXT: 5c: eb 25 jmp {{.*}} -# CHECK-NEXT: 5e: eb 23 jmp {{.*}} -# CHECK-NEXT: 60: eb 21 jmp {{.*}} -# CHECK-COUNT-2: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 72: 89 45 fc movl %eax, -4(%rbp) -# CHECK-NEXT: 75: 5d popq %rbp -# CHECK-NEXT: 76: 48 39 c5 cmpq %rax, %rbp -# CHECK-NEXT: 79: 74 02 je {{.*}} -# CHECK-NEXT: 7b: eb 06 jmp {{.*}} -# CHECK-NEXT: 7d: 8b 45 f4 movl -12(%rbp), %eax -# CHECK-NEXT: 80: 89 45 fc movl %eax, -4(%rbp) -# CHECK-COUNT-10: : 89 b5 50 fb ff ff movl %esi, -1200(%rbp) -# CHECK: bf: eb c2 jmp {{.*}} -# CHECK-NEXT: c1: c3 retq diff --git a/llvm/test/MC/X86/align-branch-64-1d.s b/llvm/test/MC/X86/align-branch-64-1d.s deleted file mode 100644 index 902bb69fec16..000000000000 --- a/llvm/test/MC/X86/align-branch-64-1d.s +++ /dev/null @@ -1,38 +0,0 @@ -# Check only conditional jumps and unconditional jumps are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=jcc+jmp -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=jcc+jmp %p/Inputs/align-branch-64-1.s | llvm-objdump -d - > %t1 -# RUN: FileCheck --input-file=%t1 %s --check-prefixes=CHECK,SHORT-NOP - -# Check long NOP can be emitted to align branch if the target cpu support long nop. -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 -mcpu=x86-64 --x86-align-branch=jcc+jmp %p/Inputs/align-branch-64-1.s | llvm-objdump -d - >%t2 -# RUN: FileCheck --input-file=%t2 %s --check-prefixes=CHECK,LONG-NOP - -# CHECK: 0000000000000000 : -# 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-NEXT: 1d: 48 39 c5 cmpq %rax, %rbp -# CHECK-NEXT: 20: 74 5d je {{.*}} -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 3a: 31 c0 xorl %eax, %eax -# CHECK-NEXT: 3c: 74 41 je {{.*}} -# CHECK-NEXT: 3e: 5d popq %rbp -# CHECK-NEXT: 3f: 90 nop -# CHECK-NEXT: 40: 74 3d je {{.*}} -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 5a: 31 c0 xorl %eax, %eax -# CHECK-NEXT: 5c: eb 27 jmp {{.*}} -# SHORT-NOP-COUNT-2: : 90 nop -# LONG-NOP: 5e: 66 90 nop -# CHECK-NEXT: 60: eb 23 jmp {{.*}} -# CHECK-NEXT: 62: eb 21 jmp {{.*}} -# CHECK-COUNT-2: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 74: 89 45 fc movl %eax, -4(%rbp) -# CHECK-NEXT: 77: 5d popq %rbp -# CHECK-NEXT: 78: 48 39 c5 cmpq %rax, %rbp -# CHECK-NEXT: 7b: 74 02 je {{.*}} -# CHECK-NEXT: 7d: eb 06 jmp {{.*}} -# CHECK-NEXT: 7f: 8b 45 f4 movl -12(%rbp), %eax -# CHECK-NEXT: 82: 89 45 fc movl %eax, -4(%rbp) -# CHECK-COUNT-10: : 89 b5 50 fb ff ff movl %esi, -1200(%rbp) -# CHECK: c1: eb c2 jmp {{.*}} -# CHECK-NEXT: c3: c3 retq diff --git a/llvm/test/MC/X86/align-branch-64-2a.s b/llvm/test/MC/X86/align-branch-64-2a.s deleted file mode 100644 index f7a61c3499f0..000000000000 --- a/llvm/test/MC/X86/align-branch-64-2a.s +++ /dev/null @@ -1,17 +0,0 @@ -# Check only indirect jumps are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=indirect -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=indirect %p/Inputs/align-branch-64-2.s | llvm-objdump -d - | FileCheck %s - -# CHECK: 0000000000000000 : -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-COUNT-2: : 89 75 f4 movl %esi, -12(%rbp) -# CHECK-COUNT-2: : 90 nop -# CHECK: 20: ff e0 jmpq *%rax -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 3a: 89 75 f4 movl %esi, -12(%rbp) -# CHECK-NEXT: 3d: 55 pushq %rbp -# CHECK-NEXT: 3e: ff d0 callq *%rax -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 58: 55 pushq %rbp -# CHECK-NEXT: 59: e8 00 00 00 00 callq {{.*}} -# CHECK-COUNT-4: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 7e: ff 14 25 00 00 00 00 callq *0 diff --git a/llvm/test/MC/X86/align-branch-64-2b.s b/llvm/test/MC/X86/align-branch-64-2b.s deleted file mode 100644 index d483cda99611..000000000000 --- a/llvm/test/MC/X86/align-branch-64-2b.s +++ /dev/null @@ -1,17 +0,0 @@ -# Check only calls are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=call -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=call %p/Inputs/align-branch-64-2.s | llvm-objdump -d - | FileCheck %s - -# CHECK: 0000000000000000 : -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-COUNT-2: : 89 75 f4 movl %esi, -12(%rbp) -# CHECK: 1e: ff e0 jmpq *%rax -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 38: 89 75 f4 movl %esi, -12(%rbp) -# CHECK-NEXT: 3b: 55 pushq %rbp -# CHECK-NEXT: 3c: ff d0 callq *%rax -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 56: 55 pushq %rbp -# CHECK-NEXT: 57: e8 00 00 00 00 callq {{.*}} -# CHECK-COUNT-4: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-COUNT-4: : 90 nop -# CHECK: 80: ff 14 25 00 00 00 00 callq *0 diff --git a/llvm/test/MC/X86/align-branch-64-2c.s b/llvm/test/MC/X86/align-branch-64-2c.s deleted file mode 100644 index 9c047f0f6a24..000000000000 --- a/llvm/test/MC/X86/align-branch-64-2c.s +++ /dev/null @@ -1,19 +0,0 @@ -# Check only indirect jumps and calls are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=indirect+call -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=indirect+call %p/Inputs/align-branch-64-2.s | llvm-objdump -d - | FileCheck %s - -# CHECK: 0000000000000000 : -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-COUNT-2: : 89 75 f4 movl %esi, -12(%rbp) -# CHECK-COUNT-2: : 90 nop -# CHECK: 20: ff e0 jmpq *%rax -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 3a: 89 75 f4 movl %esi, -12(%rbp) -# CHECK-NEXT: 3d: 55 pushq %rbp -# CHECK-COUNT-2: : 90 nop -# CHECK: 40: ff d0 callq *%rax -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 5a: 55 pushq %rbp -# CHECK-COUNT-5: : 90 nop -# CHECK: 60: e8 00 00 00 00 callq {{.*}} -# CHECK-COUNT-4: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 85: ff 14 25 00 00 00 00 callq *0 diff --git a/llvm/test/MC/X86/align-branch-64-3a.s b/llvm/test/MC/X86/align-branch-64-3a.s deleted file mode 100644 index 3df9347cad30..000000000000 --- a/llvm/test/MC/X86/align-branch-64-3a.s +++ /dev/null @@ -1,41 +0,0 @@ -# Check NOP padding is disabled before instruction that has variant symbol operand. -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=jmp+call %s | llvm-objdump -d - | FileCheck %s - -# CHECK: 0000000000000000 : -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-COUNT-2: : 48 89 e5 movq %rsp, %rbp -# CHECK: 1e: e8 00 00 00 00 callq {{.*}} -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 3b: 55 pushq %rbp -# CHECK-NEXT: 3c: 89 75 f4 movl %esi, -12(%rbp) -# CHECK-NEXT: 3f: ff 15 00 00 00 00 callq *(%rip) -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 5d: ff 15 00 00 00 00 callq *(%rip) -# CHECK-NEXT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 7b: ff 25 00 00 00 00 jmpq *(%rip) - - .text - .globl foo - .p2align 4 -foo: - .rept 3 - movl %eax, %fs:0x1 - .endr - .rept 2 - movq %rsp, %rbp - .endr - call __tls_get_addr@PLT - .rept 3 - movl %eax, %fs:0x1 - .endr - pushq %rbp - movl %esi, -12(%rbp) - call *__tls_get_addr@GOTPCREL(%rip) - .rept 3 - movl %eax, %fs:0x1 - .endr - call *foo@GOTPCREL(%rip) - .rept 3 - movl %eax, %fs:0x1 - .endr - jmp *foo@GOTPCREL(%rip) diff --git a/llvm/test/MC/X86/align-branch-64-4a.s b/llvm/test/MC/X86/align-branch-64-4a.s deleted file mode 100644 index e7b1e8c9d87b..000000000000 --- a/llvm/test/MC/X86/align-branch-64-4a.s +++ /dev/null @@ -1,33 +0,0 @@ -# Check only rets are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=ret -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=ret %s | llvm-objdump -d - | FileCheck %s - -# CHECK: 0000000000000000 : -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-COUNT-2: : 48 89 e5 movq %rsp, %rbp -# CHECK: 1e: 5a popq %rdx -# CHECK-NEXT: 1f: 90 nop -# CHECK-NEXT: 20: c3 retq -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 39: 89 75 f4 movl %esi, -12(%rbp) -# CHECK-NEXT: 3c: 31 c0 xorl %eax, %eax -# CHECK-COUNT-2: : 90 nop -# CHECK: 40: c2 1e 00 retq $30 - - .text - .globl foo - .p2align 4 -foo: - .rept 3 - movl %eax, %fs:0x1 - .endr - .rept 2 - movq %rsp, %rbp - .endr - popq %rdx - ret - .rept 3 - movl %eax, %fs:0x1 - .endr - movl %esi, -12(%rbp) - xorl %eax, %eax - ret $30 diff --git a/llvm/test/MC/X86/align-branch-64-5a.s b/llvm/test/MC/X86/align-branch-64-5a.s deleted file mode 100644 index b78b743b88da..000000000000 --- a/llvm/test/MC/X86/align-branch-64-5a.s +++ /dev/null @@ -1,43 +0,0 @@ -# Check no nop is inserted if no branch cross or is against the boundary -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret %s | llvm-objdump -d - > %t1 -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d - > %t2 -# RUN: cmp %t1 %t2 -# RUN: FileCheck --input-file=%t1 %s - -# CHECK: 0000000000000000 : -# CHECK-COUNT-3: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 18: c1 e9 02 shrl $2, %ecx -# CHECK-NEXT: 1b: 89 d1 movl %edx, %ecx -# CHECK-NEXT: 1d: 75 fc jne {{.*}} -# CHECK-NEXT: 1f: 55 pushq %rbp -# CHECK-NEXT: 20: f6 c2 02 testb $2, %dl -# CHECK-NEXT: 23: 75 fa jne {{.*}} -# CHECK-COUNT-2: : 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK: 35: c1 e9 02 shrl $2, %ecx -# CHECK-NEXT: 38: e8 c3 ff ff ff callq {{.*}} -# CHECK-NEXT: 3d: ff e0 jmpq *%rax -# CHECK-NEXT: 3f: 55 pushq %rbp -# CHECK-NEXT: 40: c2 63 00 retq $99 - - .text - .p2align 4 -foo: - .rept 3 - movl %eax, %fs:0x1 - .endr - shrl $2, %ecx -.L1: - movl %edx, %ecx - jne .L1 -.L2: - push %rbp - testb $2, %dl - jne .L2 - .rept 2 - movl %eax, %fs:0x1 - .endr - shrl $2, %ecx - call foo - jmp *%rax - push %rbp - ret $99 diff --git a/llvm/test/MC/X86/align-branch-64-6a.s b/llvm/test/MC/X86/align-branch-64-6a.s deleted file mode 100644 index 0a78eb556fa7..000000000000 --- a/llvm/test/MC/X86/align-branch-64-6a.s +++ /dev/null @@ -1,50 +0,0 @@ -# Check option --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret can cowork with option --mc-relax-all -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret --mc-relax-all %s | llvm-objdump -d - > %t1 -# RUN: FileCheck --input-file=%t1 %s - -# CHECK: 0000000000000000 : -# CHECK-NEXT: 0: 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 8: 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 10: 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 18: c1 e9 02 shrl $2, %ecx -# CHECK-NEXT: 1b: 89 d1 movl %edx, %ecx -# CHECK-NEXT: 1d: 90 nop -# CHECK-NEXT: 1e: 90 nop -# CHECK-NEXT: 1f: 90 nop -# CHECK-NEXT: 20: 0f 85 f5 ff ff ff jne {{.*}} -# CHECK-NEXT: 26: 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 2e: 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 36: f6 c2 02 testb $2, %dl -# CHECK-NEXT: 39: 0f 85 e7 ff ff ff jne {{.*}} -# CHECK-NEXT: 3f: 90 nop -# CHECK-NEXT: 40: e9 d6 ff ff ff jmp {{.*}} -# CHECK-NEXT: 45: 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 4d: 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 55: 64 89 04 25 01 00 00 00 movl %eax, %fs:1 -# CHECK-NEXT: 5d: 90 nop -# CHECK-NEXT: 5e: 90 nop -# CHECK-NEXT: 5f: 90 nop -# CHECK-NEXT: 60: e8 9b ff ff ff callq {{.*}} -# CHECK-NEXT: 65: e9 bc ff ff ff jmp {{.*}} - .text - .p2align 4 -foo: - .rept 3 - movl %eax, %fs:0x1 - .endr - shrl $2, %ecx -.L1: - movl %edx, %ecx - jne .L1 -.L2: - .rept 2 - movl %eax, %fs:0x1 - .endr - testb $2, %dl - jne .L2 - jmp .L1 - .rept 3 - movl %eax, %fs:0x1 - .endr - call foo - jmp .L2 diff --git a/llvm/test/MC/X86/align-branch-64-align.s b/llvm/test/MC/X86/align-branch-64-align.s new file mode 100644 index 000000000000..d5bed5b4ab69 --- /dev/null +++ b/llvm/test/MC/X86/align-branch-64-align.s @@ -0,0 +1,26 @@ + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+call %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s + + # Exercise some corner cases related to align directive. + + .text + # Check the align directive between the macro fused pair + # does not make code crazy. + # CHECK: 0: cmpq %rax, %rbp + # CHECK: 3: nop + # CHECK: 4: jne + cmp %rax, %rbp + .p2align 1 + jne bar + + .rept 24 + int3 + .endr + .p2align 1 + # Check we can ensure this call not cross or end at boundary when there + # is a align directive before it. + # CHECK: 20: callq *%rax + call *%rax + + .type bar,@function +bar: + retq diff --git a/llvm/test/MC/X86/align-branch-64.s b/llvm/test/MC/X86/align-branch-64-basic.s similarity index 100% rename from llvm/test/MC/X86/align-branch-64.s rename to llvm/test/MC/X86/align-branch-64-basic.s diff --git a/llvm/test/MC/X86/align-branch-64-7a.s b/llvm/test/MC/X86/align-branch-64-bundle.s similarity index 100% rename from llvm/test/MC/X86/align-branch-64-7a.s rename to llvm/test/MC/X86/align-branch-64-bundle.s diff --git a/llvm/test/MC/X86/align-branch-64-fused.s b/llvm/test/MC/X86/align-branch-64-fused.s new file mode 100644 index 000000000000..750afd713744 --- /dev/null +++ b/llvm/test/MC/X86/align-branch-64-fused.s @@ -0,0 +1,42 @@ + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s + + # Exercise cases where fused instructions need to be aligned. + + .text + .globl foo +foo: + .p2align 5 + .rept 30 + int3 + .endr + # 'cmp %rax, %rbp' is macro fused with 'jne foo', + # so we need to align the pair. + # CHECK: 20: cmpq %rax, %rbp + # CHECK: 23: jne + cmp %rax, %rbp + jne foo + int3 + + .p2align 5 + .rept 28 + int3 + .endr + # 'cmp %rax, %rbp' is fusible but can not fused with `jo foo`, + # so we only need to align 'jo foo'. + # CHECK: 5c: cmpq %rax, %rbp + cmp %rax, %rbp + # CHECK: 60: jo + jo foo + int3 + + .p2align 5 + .rept 26 + int3 + .endr + # The second 'cmp %rax, %rbp' is macro fused with 'jne foo'. + cmp %rax, %rbp + # CHECK: a0: cmpq %rax, %rbp + # CHECK: a3: jne + cmp %rax, %rbp + jne foo + int3 diff --git a/llvm/test/MC/X86/align-branch-64-general.s b/llvm/test/MC/X86/align-branch-64-general.s new file mode 100644 index 000000000000..f354cc7c9720 --- /dev/null +++ b/llvm/test/MC/X86/align-branch-64-general.s @@ -0,0 +1,49 @@ + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp %s -o %t1 + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-branches-within-32B-boundaries %s -o %t2 + # RUN: cmp %t1 %t2 + + # Check the general option --x86-branches-within-32B-boundaries is equivelent + # to the fined options --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp. + + .text + .globl foo + .p2align 5 +foo: + .p2align 5 + .rept 30 + int3 + .endr + js foo + + .p2align 5 + .rept 30 + int3 + .endr + jmp foo + + .p2align 5 + .rept 30 + int3 + .endr + jmp *%rcx + + + .p2align 5 + .rept 30 + int3 + .endr + call foo + + .p2align 5 + .rept 30 + int3 + .endr + ret $0 + + + .p2align 5 + .rept 29 + int3 + .endr + cmp %rax, %rbp + je foo diff --git a/llvm/test/MC/X86/align-branch-64-mixed.s b/llvm/test/MC/X86/align-branch-64-mixed.s new file mode 100644 index 000000000000..2fa46fe71e9c --- /dev/null +++ b/llvm/test/MC/X86/align-branch-64-mixed.s @@ -0,0 +1,51 @@ + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=jcc+jmp+indirect+call+ret %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s + + # Exercise cases where mixed kinds of branch are asked to be aligned. + + .text + .globl labeled_mixed_test1 +labeled_mixed_test1: + .p2align 5 + .rept 30 + int3 + .endr + # This call should have started at 0x1e and ends at 0x23, so two bytes of + # padding are inserted before it. + # CHECK: 20: callq + call bar + .rept 28 + int3 + .endr + # If the previous call was not aligned, this jmp should have started at 0x3f + # and need two bytes of padding. After the two bytes of padding are inserted + # for the call, this jmp starts at 0xa1 and does not need padding. + # CHECK: 41: jmp + jmp *%rax + + .globl labeled_mixed_test2 +labeled_mixed_test2: + .p2align 5 + .rept 30 + int3 + .endr + # This jne should have started at 0x7e, so two bytes of padding are inserted + # before it. + # CHECK: 80: jne + jne bar + .rept 28 + int3 + .endr + # If the previous jne was not aligned, this jmp should have started at 0x3c. + # After the two bytes of padding are inserted for the jne, this jmp should + # have started at 0x9e, so two bytes of padding are inserted and it starts at + # 0xa0. + # CHECK: a0: jmp + jmp bar + + .globl labeled_mixed_test3 +labeled_mixed_test3: + .p2align 5 + .type bar,@function +bar: + # CHECK: c0: retq + retq diff --git a/llvm/test/MC/X86/align-branch-64-necessary.s b/llvm/test/MC/X86/align-branch-64-necessary.s new file mode 100644 index 000000000000..960bb92ed703 --- /dev/null +++ b/llvm/test/MC/X86/align-branch-64-necessary.s @@ -0,0 +1,54 @@ + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+indirect+call+ret %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s + + # Check if no instruction crosses or is against the boundary, + # there will be no extra padding. + + .text + .globl foo + .p2align 5 +foo: + .p2align 5 + .rept 24 + int3 + .endr + # CHECK: 18: js + js foo + + .p2align 5 + .rept 24 + int3 + .endr + # CHECK: 38: jmp + jmp foo + + .p2align 5 + .rept 24 + int3 + .endr + # CHECK: 58: jmpq *%rcx + jmp *%rcx + + + .p2align 5 + .rept 24 + int3 + .endr + # CHECK: 78: callq + call foo + + .p2align 5 + .rept 27 + int3 + .endr + # CHECK: 9b: retq $0 + ret $0 + + + .p2align 5 + .rept 21 + int3 + .endr + # CHECK: b5: cmpq %rax, %rbp + # CHECK: b8: je + cmp %rax, %rbp + je foo diff --git a/llvm/test/MC/X86/align-branch-64-relax-all.s b/llvm/test/MC/X86/align-branch-64-relax-all.s new file mode 100644 index 000000000000..112629608f2d --- /dev/null +++ b/llvm/test/MC/X86/align-branch-64-relax-all.s @@ -0,0 +1,42 @@ + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc --mc-relax-all %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s + + # Check instructions can be aligned correctly along with option --mc-relax-all + + .text + .global foo +foo: + .p2align 5 + .rept 25 + int3 + .endr + # CHECK: 19: jne + # CHECK: 1f: int3 + jne foo + int3 + + .p2align 5 + .rept 27 + int3 + .endr + # CHECK: 40: jne + jne foo + + .p2align 5 + .rept 22 + int3 + .endr + # CHECK: 76: testb $2, %dl + # CHECK: 79: jne + # CHECK: 7f: int3 + testb $2, %dl + jne foo + int3 + + .p2align 5 + .rept 27 + int3 + .endr + # CHECK: a0: testb $2, %dl + # CHECK: a3: jne + testb $2, %dl + jne foo diff --git a/llvm/test/MC/X86/align-branch-64-section-size.s b/llvm/test/MC/X86/align-branch-64-section-size.s new file mode 100644 index 000000000000..e4c9fbf3f039 --- /dev/null +++ b/llvm/test/MC/X86/align-branch-64-section-size.s @@ -0,0 +1,20 @@ + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=ret %s | llvm-readobj -S | FileCheck %s + + # Check the aligment of section that contains instructions to be aligned + # is correctly set. + + # CHECK: Name: text1 + # CHECK: AddressAlignment: 32 + .section text1 +foo: + ret + + # CHECK: Name: text2 + # CHECK: AddressAlignment: 1 + .section text2 + nop + + # CHECK: Name: text3 + # CHECK: AddressAlignment: 1 + .section text3 + jmp foo diff --git a/llvm/test/MC/X86/align-branch-64-single.s b/llvm/test/MC/X86/align-branch-64-single.s new file mode 100644 index 000000000000..54ac2e4ae573 --- /dev/null +++ b/llvm/test/MC/X86/align-branch-64-single.s @@ -0,0 +1,93 @@ + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=jcc %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s --check-prefixes=JCC + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=jmp %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s --check-prefixes=JMP + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=indirect %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s --check-prefixes=IND + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=call %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s --check-prefixes=CAL + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=ret %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s --check-prefixes=RET + + # Exercise cases where only one kind of instruction is asked to be aligned. + # Fused instruction cases are excluded. + + .text + .globl foo + .p2align 5 +foo: + .p2align 5 + .rept 30 + int3 + .endr + # JCC: 20: jne + # JMP: 1e: jne + # IND: 1e: jne + # CAL: 1e: jne + # RET: 1e: jne + jne foo + int3 + + .p2align 5 + .rept 30 + int3 + .endr + # JCC: 5e: jmp + # JMP: 60: jmp + # IND: 5e: jmp + # CAL: 5e: jmp + # RET: 5e: jmp + jmp foo + int3 + + .p2align 5 + .rept 30 + int3 + .endr + # JCC: 9e: jmpq *%rax + # JMP: 9e: jmpq *%rax + # IND: a0: jmpq *%rax + # CAL: 9e: jmpq *%rax + # RET: 9e: jmpq *%rax + jmp *%rax + int3 + + + .p2align 5 + .rept 30 + int3 + .endr + # JCC: de: callq *%rax + # JMP: de: callq *%rax + # IND: de: callq *%rax + # CAL: e0: callq *%rax + # RET: de: callq *%rax + call *%rax + int3 + + + .p2align 5 + .rept 30 + int3 + .endr + # JCC: 11e: retq + # JMP: 11e: retq + # IND: 11e: retq + # CAL: 11e: retq + # RET: 120: retq + ret $0 + int3 + + + .p2align 5 + .rept 29 + int3 + .endr + # JCC: 15d: cmpq %rax, %rbp + # JCC: 160: je + # JMP: 15d: cmpq %rax, %rbp + # JMP: 160: je + # IND: 15d: cmpq %rax, %rbp + # IND: 160: je + # CAL: 15d: cmpq %rax, %rbp + # CAL: 160: je + # RET: 15d: cmpq %rax, %rbp + # RET: 160: je + cmp %rax, %rbp + je foo + int3 diff --git a/llvm/test/CodeGen/X86/align-branch-boundary-default.s b/llvm/test/MC/X86/align-branch-boundary-default.s similarity index 100% rename from llvm/test/CodeGen/X86/align-branch-boundary-default.s rename to llvm/test/MC/X86/align-branch-boundary-default.s diff --git a/llvm/test/MC/X86/align-branch-variant-symbol.s b/llvm/test/MC/X86/align-branch-variant-symbol.s new file mode 100644 index 000000000000..e1cb7b52edc2 --- /dev/null +++ b/llvm/test/MC/X86/align-branch-variant-symbol.s @@ -0,0 +1,57 @@ + # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=call+indirect %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s --check-prefixes=64BIT,CHECK + + # RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=call+indirect %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s --check-prefixes=32BIT,CHECK + + # Exercise cases where the instruction to be aligned has a variant symbol + # operand, and we can't add before it since linker may rewrite it. + + .text + .global foo + +foo: + .p2align 5 + .rept 30 + int3 + .endr + # CHECK: 1d: int3 + # 64BIT: 1e: callq + # 32BIT: 1e: calll + # CHECK: 23: int3 + call ___tls_get_addr@PLT + int3 + + .p2align 5 + .rept 30 + int3 + .endr + # CHECK: 5d: int3 + # 64BIT: 5e: callq *(%ecx) + # 64BIT: 65: int3 + # 32BIT: 5e: calll *(%ecx) + # 32BIT: 64: int3 + call *___tls_get_addr@GOT(%ecx) + int3 + + .p2align 5 + .rept 30 + int3 + .endr + # CHECK: 9d: int3 + # 64BIT: 9e: callq *(%eax) + # 64BIT: a1: int3 + # 32BIT: 9e: calll *(%eax) + # 32BIT: a0: int3 + call *foo@tlscall(%eax) + int3 + + .p2align 5 + .rept 30 + int3 + .endr + # CHECK: dd: int3 + # 64BIT: de: jmpq *(%eax) + # 64BIT: e1: int3 + # 32BIT: de: jmpl *(%eax) + # 32BIT: e0: int3 + jmp *foo@tlscall(%eax) + int3