[BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- R_X86_64_64.pic.lld.cpp
- avx512_trap.test
- bad_exe.test
- bolt_info.test

(cherry picked from FBD31251439)
This commit is contained in:
Amir Ayupov 2021-09-28 15:47:51 -07:00 committed by Maksim Panchenko
parent 62550dd22c
commit 47455e98b3
6 changed files with 92 additions and 0 deletions

View file

@ -0,0 +1,15 @@
#include <stdio.h>
void use_avx512() {
printf("after first entry\n");
asm (".byte 0x62, 0xe2, 0xf5, 0x70, 0x2c, 0xda");
asm ("secondary_entry:");
printf("after secondary entry\n");
}
int main() {
printf("about to use avx-512 instruction...\n");
use_avx512();
return 0;
}

View file

@ -0,0 +1,29 @@
#include <stdio.h>
int inc(int x) {
switch (x) {
case 0: puts("0"); return 1;
case 1: puts("1"); return 2;
case 2: puts("2"); return 3;
case 3: puts("3"); return 4;
case 4: puts("4"); return 5;
case 5: puts("5"); return 6;
default: return x + 1;
}
}
int inc_dup(int x) {
switch (x) {
case 0: puts("0"); return 1;
case 1: puts("1"); return 2;
case 2: puts("2"); return 3;
case 3: puts("3"); return 4;
case 4: puts("4"); return 5;
case 5: puts("5"); return 6;
default: return x + 1;
}
}
int main() {
return inc(5) - 2*inc_dup(2);
}

View file

@ -0,0 +1,15 @@
/*
* Check that we don't assert on a duplicate static relocation added by lld
* against _Z6myfuncv. The same address has a dynamic relocation against it.
*
* RUN: %clang -fPIC -shared %s -o %t.so -Wl,-q -fuse-ld=ld.lld
* RUN: llvm-bolt %t.so -o %t.so.bolt -relocs
*/
unsigned long long myfunc();
unsigned long long (*myglobal)() = myfunc;
unsigned long long myfunc() {
return reinterpret_cast<unsigned long long>(myglobal);
}

View file

@ -0,0 +1,19 @@
# Check that BOLT inserts trap instruction at entry to functions that use AVX-512.
# Check that AVX-512 instruction is updated correctly when -trap-avx512=0 is passed.
RUN: %clang %S/Inputs/avx512.c -o %t -Wl,-q,-znow
RUN: llvm-bolt %t -trap-avx512=1 -o %t.bolt 2>&1 | FileCheck %s && \
RUN: llvm-objdump -d --disassemble-symbols=use_avx512 %t.bolt | FileCheck %s --check-prefix=CHECK-DIS
RUN: llvm-bolt %t -trap-avx512=0 -o %t.bolt && \
RUN: llvm-objdump -d --disassemble-symbols=use_avx512 %t.bolt | FileCheck %s --check-prefix=CHECK-DIS-NO-TRAP
CHECK: BOLT-WARNING: 1 function will trap on entry
# Check that we have two ud2 instructions - one per entry.
CHECK-DIS: use_avx512
CHECK-DIS-NEXT: ud2
CHECK-DIS-NEXT: ud2
# Check that we generate correct AVX-512
CHECK-DIS-NO-TRAP: use_avx512
CHECK-DIS-NO-TRAP: 62 e2 f5 70 2c da vscalefpd

View file

@ -0,0 +1,7 @@
# Check that llvm-bolt rejects input that is not a valid ELF executable
# bzip2.debuginfo is the result of running "objcopy --only-keep-debug".
RUN: %clang %S/Inputs/switch_statement.cpp -g -o %t
RUN: llvm-objcopy --only-keep-debug %t %t.debuginfo
RUN: not llvm-bolt %t.debuginfo -o /dev/null |& FileCheck %s
CHECK: input binary is not a valid ELF executable

View file

@ -0,0 +1,7 @@
# Check that the .bolt_info section is generated properly.
RUN: %clang %S/Inputs/switch_statement.cpp -o %t
RUN: llvm-bolt %t -o %t.bolt && \
RUN: llvm-objdump -s -j .note.bolt_info %t.bolt | grep -v "file format" | \
RUN: cut -c 44- | tr -d '\n' | FileCheck %s
CHECK: BOLT revision: {{.*}}, command line: {{.*}}llvm-bolt {{.*}}/bolt_info.test.tmp -o {{.*}}/bolt_info.test.tmp.bolt