[BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- invalid_profile.test
- internal_call.test
- internal_call_instrument.test

(cherry picked from FBD31452386)
This commit is contained in:
Amir Ayupov 2021-10-06 14:25:29 -07:00 committed by Maksim Panchenko
parent e424d16f0e
commit b86c91eae0
5 changed files with 149 additions and 0 deletions

View file

@ -0,0 +1,6 @@
# Check that llvm-bolt detects bad profile data and aborts
RUN: %clang %S/Inputs/icf-jump-tables.c -o %t
RUN: not llvm-bolt %t -o %t.bolt -data %t |& FileCheck %s
CHECK: no valid profile data found

View file

@ -0,0 +1,16 @@
// BOLT test case
#include <stdio.h>
typedef unsigned long long (*FP)();
extern FP getCallback();
extern FP getCallback2();
extern FP getCallback3();
int main() {
printf("Case 1: Result is: %llX\n", (*getCallback())());
printf("Case 2: Result is: %llX\n", (*getCallback2())());
printf("Case 3: Result is: %llX\n", (*getCallback3())());
return 0;
}

View file

@ -0,0 +1,101 @@
// This is reduced test case for BOLT containing an internal call based on
// GetCoreDump (from google core dumper).
.text
.globl getCallback
.type getCallback, %function
getCallback:
.cfi_startproc
pushq %rbp
movq %rsp, %rbp
pushq %r12
pushq %rbx
subq $288, %rsp
callq .Lnext_instr
.Lnext_instr:
popq %rax
addq $17, %rax
addq $288, %rsp
popq %rbx
popq %r12
popq %rbp
retq
.Lweird_callback:
mov $0xDEADBEEF, %rax
retq
.cfi_endproc
// This one is inspired by:
//
// e8 11 00 00 00 callq 17 <ListerThread+0x569>
// 0f 1f 84 00 00 00 00 00 nopl (%rax,%rax)
// 48 c7 c0 0f 00 00 00 movq $15, %rax
// 0f 05 syscall
// 58 popq %rax
//
.globl getCallback2
.type getCallback2, %function
getCallback2:
.cfi_startproc
pushq %rbp
movq %rsp, %rbp
pushq %r12
pushq %rbx
subq $288, %rsp
movq $3, %rbx
.Lheader:
cmpq $0, %rbx
jz .Lunwind
callq .Lbb
nopl (%rax, %rax)
mov $0xDEADBEEF, %rax
retq
.Lunwind:
addq $288, %rsp
popq %rbx
popq %r12
jmp .Lend
.Lbb:
popq %rax
add $4, %rax
decq %rbx
jmp .Lheader
.Lend:
popq %rbp
retq
.cfi_endproc
// This case emulates pseudo-inlined functions found in Intel MKL library.
.globl getCallback3
.type getCallback3, %function
getCallback3:
.cfi_startproc
pushq %rbp
movq %rsp, %rbp
callq getCallback_inlined
jmp .L2end
nop
getCallback_inlined:
pushq %rbp
movq %rsp, %rbp
pushq %r12
pushq %rbx
subq $288, %rsp
callq .L2next_instr
.L2next_instr:
popq %rax
addq $17, %rax
addq $288, %rsp
popq %rbx
popq %r12
popq %rbp
retq
.L2weird_callback:
mov $0xDEADBEEF, %rax
retq
.L2end:
popq %rbp
retq
.cfi_endproc

View file

@ -0,0 +1,14 @@
# Verify that we support x86 old pic style internal calls accordingly in
# relocation mode
#
REQUIRES: x86_64-linux
RUN: %clang -O3 %S/Inputs/internalcall-main.c %S/Inputs/internalcall.S -Wl,-q \
RUN: -o %t.exe
RUN: llvm-bolt %t.exe -o %t -relocs -lite=0
RUN: %t | FileCheck %s
CHECK: Case 1: Result is: DEADBEEF
CHECK: Case 2: Result is: DEADBEEF
CHECK: Case 3: Result is: DEADBEEF

View file

@ -0,0 +1,12 @@
# Verify that instrumentation pass handles internal calls
REQUIRES: x86_64-linux
RUN: %clang -O3 %S/Inputs/internalcall-main.c %S/Inputs/internalcall.S -Wl,-q \
RUN: -o %t.exe
RUN: llvm-bolt -instrument %t.exe -o %t -relocs -lite=0
RUN: %t | FileCheck %s
CHECK: Case 1: Result is: DEADBEEF
CHECK: Case 2: Result is: DEADBEEF
CHECK: Case 3: Result is: DEADBEEF