[BOLT][TEST] Import small tests

Summary: Imported small internal tests.

(cherry picked from FBD32371964)
This commit is contained in:
Amir Ayupov 2021-11-11 14:28:46 -08:00 committed by Maksim Panchenko
parent c42d467276
commit 0e7dd1aad1
6 changed files with 133 additions and 0 deletions

View File

@ -0,0 +1,27 @@
.globl main
main:
jmp a
b:
callq foo
a:
jle b
.globl foo
foo:
jmp d
e:
je f
cmpl $1, g
f:
jmp j
h:
cmpl $1, 0
j:
jle h
g:
cmpl $1, 0
d:
jle e
i:
retq
# FDATA: 1 foo #i# 1 main #a# 0 1

View File

@ -0,0 +1,6 @@
.globl main
main:
subq $0x2000000, (%r13)
.byte 0x49,0x81,0x6d,0x00,0x02,0x00,0x00,0x00
xorq %rax,%rax
ret

View File

@ -0,0 +1,23 @@
.globl main
main:
movzbl s1(%rip), %eax
cmpb s2(%rip), %al
movzbl s1+1(%rip), %eax
cmpb s2+1(%rip), %al
movzbl s1+2(%rip), %eax
cmpb s2+2(%rip), %al
movzbl s1+3(%rip), %eax
cmpb s2+3(%rip), %al
movl I1(%rip), %eax
addl I2(%rip), %eax
movl I2(%rip), %eax
.rodata
"I1":
.long 6
"I2":
.long 67
"s1":
.string "ABC"
"s2":
.string "ABC"

View File

@ -0,0 +1,22 @@
# Verifies that llvm-bolt prints correct loop information.
RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
RUN: %p/Inputs/loop_nest.s -o %t.o
RUN: link_fdata %p/Inputs/loop_nest.s %t.o %t.fdata
RUN: llvm-strip --strip-unneeded %t.o
RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
RUN: llvm-bolt %t.exe -o %t -data=%t.fdata \
RUN: -print-cfg -print-loops -sequential-disassembly -lite=0 2>&1 | FileCheck %s
CHECK: Binary Function "main" after building cfg
CHECK: Loop Info for Function "main"
CHECK: Outer loop header: .Ltmp[[#MAIN_OUTER_HDR:]]
CHECK-NEXT: Loop basic blocks: .Ltmp[[#MAIN_OUTER_HDR]], .Ltmp[[#]]
CHECK: Binary Function "foo" after building cfg
CHECK: Loop Info for Function "foo"
CHECK: Outer loop header: .Ltmp[[#FOO_OUTER_HDR:]]
CHECK-NEXT: Loop basic blocks: .Ltmp[[#FOO_OUTER_HDR]], .Ltmp[[#]], .LFT[[#]], .Ltmp[[#]], .Ltmp[[#FOO_INNER_HDR:]], .Ltmp[[#]], .Ltmp[[#FOO_INNER_BB:]]
CHECK: Nested loop header: .Ltmp[[#FOO_INNER_HDR]]
CHECK-NEXT: Loop basic blocks: .Ltmp[[#FOO_INNER_HDR]], .Ltmp[[#FOO_INNER_BB]]

View File

@ -0,0 +1,11 @@
# Checks that peephole pass works.
RUN: %clang %p/Inputs/peephole.s -o %t.exe
RUN: llvm-bolt %t.exe -o %t -peepholes=shorten
RUN: llvm-objdump -d --disassemble-symbols=main %t | FileCheck %s
CHECK: main
CHECK-NEXT: 49 81 6d 00 00 00 00 02 subq $33554432, (%r13)
CHECK-NEXT: 49 83 6d 00 02 subq $2, (%r13)
CHECK-NEXT: 48 31 c0 xorq %rax, %rax
CHECK-NEXT: c3 retq

View File

@ -0,0 +1,44 @@
# Check for the simplification of .rodata loads.
RUN: %clang %p/Inputs/rodata_simpl_loads.s -o %t.exe
RUN: llvm-bolt %t.exe -o %t -simplify-rodata-loads
RUN: FileCheck %s --check-prefix=ORIGINAL --input-file %p/Inputs/rodata_simpl_loads.s
RUN: llvm-objdump -d %t --print-imm-hex --disassemble-symbols=main | FileCheck %s
CHECK: Disassembly of section .text:
CHECK: <main>:
# check that the following rip-relative operands have been
# replaced with immediates
ORIGINAL: movzbl s1(%rip), %eax
CHECK: movl $0x41, %eax
ORIGINAL: cmpb s2(%rip), %al
CHECK: cmpb $0x41, %al
ORIGINAL: movzbl s1+1(%rip), %eax
CHECK: movl $0x42, %eax
ORIGINAL: cmpb s2+1(%rip), %al
CHECK: cmpb $0x42, %al
ORIGINAL: movzbl s1+2(%rip), %eax
CHECK: movl $0x43, %eax
ORIGINAL: cmpb s2+2(%rip), %al
CHECK: cmpb $0x43, %al
ORIGINAL: movzbl s1+3(%rip), %eax
CHECK: movl $0x0, %eax
ORIGINAL: cmpb s2+3(%rip), %al
CHECK: cmpb $0x0, %al
ORIGINAL: movl I1(%rip), %eax
CHECK: movl $0x6, %eax
ORIGINAL: addl I2(%rip), %eax
CHECK: addl $0x43, %eax
ORIGINAL: movl I2(%rip), %eax
CHECK: movl $0x43, %eax