forked from OSchip/llvm-project
Tests for the aligned bundling support added in r170718
llvm-svn: 170719
This commit is contained in:
parent
f483ff9204
commit
4c4f11eb0d
|
@ -0,0 +1,37 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple armv7-linux-gnueabi %s -o - \
|
||||
# RUN: | llvm-objdump -no-show-raw-insn -triple armv7 -disassemble - | FileCheck %s
|
||||
|
||||
# On ARM each instruction is 4 bytes long so padding for individual
|
||||
# instructions should not be inserted. However, for bundle=locked groups
|
||||
# it can be.
|
||||
|
||||
.syntax unified
|
||||
.text
|
||||
.bundle_align_mode 4
|
||||
|
||||
bx lr
|
||||
and r1, r1, r2
|
||||
and r1, r1, r2
|
||||
.bundle_lock
|
||||
bx r9
|
||||
bx r8
|
||||
.bundle_unlock
|
||||
# CHECK: c: nop
|
||||
# CHECK-NEXT: 10: bx
|
||||
# CHECK-NEXT: 14: bx
|
||||
|
||||
# pow2 here
|
||||
.align 4
|
||||
bx lr
|
||||
.bundle_lock
|
||||
bx r9
|
||||
bx r9
|
||||
bx r9
|
||||
bx r8
|
||||
.bundle_unlock
|
||||
# CHECK: 20: bx
|
||||
# CHECK-NEXT: 24: nop
|
||||
# CHECK-NEXT: 28: nop
|
||||
# CHECK-NEXT: 2c: nop
|
||||
# CHECK-NEXT: 30: bx
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
config.suffixes = ['.s']
|
||||
|
||||
targets = set(config.root.targets_to_build.split())
|
||||
if not 'X86' in targets:
|
||||
config.unsupported = True
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
|
||||
|
||||
# Missing .bundle_align_mode argument
|
||||
# CHECK: error: unknown token
|
||||
|
||||
.bundle_align_mode
|
||||
imull $17, %ebx, %ebp
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# RUN: llvm-mc -filetype=asm -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
|
||||
|
||||
# Just a simple test for the assembly emitter - making sure it emits back the
|
||||
# bundling directives.
|
||||
|
||||
.text
|
||||
foo:
|
||||
.bundle_align_mode 4
|
||||
# CHECK: .bundle_align_mode 4
|
||||
pushq %rbp
|
||||
.bundle_lock
|
||||
# CHECK: .bundle_lock
|
||||
cmpl %r14d, %ebp
|
||||
jle .L_ELSE
|
||||
.bundle_unlock
|
||||
# CHECK: .bundle_unlock
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
|
||||
|
||||
# CHECK: ERROR: Fragment can't be larger than a bundle size
|
||||
|
||||
.text
|
||||
foo:
|
||||
.bundle_align_mode 4
|
||||
pushq %rbp
|
||||
|
||||
.bundle_lock
|
||||
pushq %r14
|
||||
callq bar
|
||||
callq bar
|
||||
callq bar
|
||||
callq bar
|
||||
.bundle_unlock
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
|
||||
# RUN: | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck %s
|
||||
|
||||
# Test two different executable sections with bundling.
|
||||
|
||||
.bundle_align_mode 3
|
||||
.section text1, "x"
|
||||
# CHECK: section text1
|
||||
imull $17, %ebx, %ebp
|
||||
imull $17, %ebx, %ebp
|
||||
|
||||
imull $17, %ebx, %ebp
|
||||
# CHECK: 6: nop
|
||||
# CHECK-NEXT: 8: imull
|
||||
|
||||
.section text2, "x"
|
||||
# CHECK: section text2
|
||||
imull $17, %ebx, %ebp
|
||||
imull $17, %ebx, %ebp
|
||||
|
||||
imull $17, %ebx, %ebp
|
||||
# CHECK: 6: nop
|
||||
# CHECK-NEXT: 8: imull
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
config.suffixes = ['.s']
|
||||
|
||||
targets = set(config.root.targets_to_build.split())
|
||||
if not 'X86' in targets:
|
||||
config.unsupported = True
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
|
||||
|
||||
# .bundle_lock can't come without a .bundle_align_mode before it
|
||||
|
||||
# CHECK: ERROR: .bundle_lock forbidden when bundling is disabled
|
||||
|
||||
imull $17, %ebx, %ebp
|
||||
.bundle_lock
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
|
||||
# RUN: | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck %s
|
||||
|
||||
# Test some variations of padding for bundle-locked groups.
|
||||
|
||||
.text
|
||||
foo:
|
||||
.bundle_align_mode 4
|
||||
|
||||
# Each of these callq instructions is 5 bytes long
|
||||
callq bar
|
||||
callq bar
|
||||
|
||||
.bundle_lock
|
||||
callq bar
|
||||
callq bar
|
||||
.bundle_unlock
|
||||
# We'll need a 6-byte NOP before this group
|
||||
# CHECK: a: nop
|
||||
# CHECK-NEXT: 10: callq
|
||||
# CHECK-NEXT: 15: callq
|
||||
|
||||
.bundle_lock
|
||||
callq bar
|
||||
callq bar
|
||||
.bundle_unlock
|
||||
# Same here
|
||||
# CHECK: 1a: nop
|
||||
# CHECK-NEXT: 20: callq
|
||||
# CHECK-NEXT: 25: callq
|
||||
|
||||
.align 16, 0x90
|
||||
callq bar
|
||||
.bundle_lock
|
||||
callq bar
|
||||
callq bar
|
||||
callq bar
|
||||
.bundle_unlock
|
||||
# And here we'll need a 11-byte NOP
|
||||
# CHECK: 30: callq
|
||||
# CHECK: 35: nop
|
||||
# CHECK-NEXT: 40: callq
|
||||
# CHECK-NEXT: 45: callq
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
|
||||
# RUN: | llvm-objdump -disassemble - | FileCheck %s
|
||||
|
||||
# Test that instructions inside bundle-locked groups are relaxed even if their
|
||||
# fixup is short enough not to warrant relaxation on its own.
|
||||
|
||||
.text
|
||||
foo:
|
||||
.bundle_align_mode 4
|
||||
pushq %rbp
|
||||
|
||||
movl %edi, %ebx
|
||||
callq bar
|
||||
movl %eax, %r14d
|
||||
imull $17, %ebx, %ebp
|
||||
movl %ebx, %edi
|
||||
callq bar
|
||||
cmpl %r14d, %ebp
|
||||
.bundle_lock
|
||||
|
||||
jle .L_ELSE
|
||||
# This group would've started at 0x18 and is too long, so a chunky NOP padding
|
||||
# is inserted to push it to 0x20.
|
||||
# CHECK: 18: {{[a-f0-9 ]+}} nopl
|
||||
|
||||
# The long encoding for JLE should be used here even though its target is close
|
||||
# CHECK-NEXT: 20: 0f 8e
|
||||
|
||||
addl %ebp, %eax
|
||||
|
||||
jmp .L_RET
|
||||
# Same for the JMP
|
||||
# CHECK: 28: e9
|
||||
|
||||
.bundle_unlock
|
||||
|
||||
.L_ELSE:
|
||||
imull %ebx, %eax
|
||||
.L_RET:
|
||||
|
||||
popq %rbx
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
|
||||
# RUN: | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck %s
|
||||
|
||||
# Test simple NOP insertion for single instructions.
|
||||
|
||||
.text
|
||||
foo:
|
||||
# Will be bundle-aligning to 16 byte boundaries
|
||||
.bundle_align_mode 4
|
||||
pushq %rbp
|
||||
pushq %r14
|
||||
pushq %rbx
|
||||
|
||||
movl %edi, %ebx
|
||||
callq bar
|
||||
movl %eax, %r14d
|
||||
|
||||
imull $17, %ebx, %ebp
|
||||
# This imull is 3 bytes long and should have started at 0xe, so two bytes
|
||||
# of nop padding are inserted instead and it starts at 0x10
|
||||
# CHECK: nop
|
||||
# CHECK-NEXT: 10: imull
|
||||
|
||||
movl %ebx, %edi
|
||||
callq bar
|
||||
cmpl %r14d, %ebp
|
||||
jle .L_ELSE
|
||||
# Due to the padding that's inserted before the addl, the jump target
|
||||
# becomes farther by one byte.
|
||||
# CHECK: jle 5
|
||||
|
||||
addl %ebp, %eax
|
||||
# CHECK: nop
|
||||
# CHECK-NEXT: 20: addl
|
||||
|
||||
jmp .L_RET
|
||||
.L_ELSE:
|
||||
imull %ebx, %eax
|
||||
.L_RET:
|
||||
ret
|
||||
|
||||
# Just sanity checking that data fills don't drive bundling crazy
|
||||
.data
|
||||
.byte 40
|
||||
.byte 98
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
|
||||
|
||||
# This test invokes .bundle_lock and then switches to a different section
|
||||
# w/o the appropriate unlock.
|
||||
|
||||
# CHECK: ERROR: Unterminated .bundle_lock
|
||||
|
||||
.bundle_align_mode 3
|
||||
.section text1, "x"
|
||||
imull $17, %ebx, %ebp
|
||||
.bundle_lock
|
||||
imull $17, %ebx, %ebp
|
||||
|
||||
.section text2, "x"
|
||||
imull $17, %ebx, %ebp
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
|
||||
|
||||
# .bundle_unlock can't come without a .bundle_lock before it
|
||||
|
||||
# CHECK: ERROR: .bundle_unlock without matching lock
|
||||
|
||||
.bundle_align_mode 3
|
||||
imull $17, %ebx, %ebp
|
||||
.bundle_unlock
|
||||
|
||||
|
Loading…
Reference in New Issue