diff --git a/bolt/test/AArch64/lit.local.cfg b/bolt/test/AArch64/lit.local.cfg --- a/bolt/test/AArch64/lit.local.cfg +++ b/bolt/test/AArch64/lit.local.cfg @@ -1,12 +1,7 @@ if 'AArch64' not in config.root.targets: config.unsupported = True -config.substitutions.insert( - 0, ('%cflags', - '%cflags --target=aarch64-pc-linux -nostartfiles -nostdlib -fuse-ld=lld' - ' -ffreestanding -Wl,--unresolved-symbols=ignore-all')) +flags = '--target=aarch64-pc-linux -nostartfiles -nostdlib -ffreestanding' -config.substitutions.insert( - 0, ('%cxxflags', - '%cxxflags --target=aarch64-pc-linux -nostartfiles -nostdlib -fuse-ld=lld' - ' -ffreestanding -Wl,--unresolved-symbols=ignore-all')) +config.substitutions.insert(0, ('%cflags', f'%cflags {flags}')) +config.substitutions.insert(0, ('%cxxflags', f'%cxxflags {flags}')) diff --git a/bolt/test/Inputs/jump_table_icp.cpp b/bolt/test/Inputs/jump_table_icp.cpp --- a/bolt/test/Inputs/jump_table_icp.cpp +++ b/bolt/test/Inputs/jump_table_icp.cpp @@ -1,5 +1,4 @@ -#include -#include +#include "stub.h" int total = 0; diff --git a/bolt/test/Inputs/stub.h b/bolt/test/Inputs/stub.h --- a/bolt/test/Inputs/stub.h +++ b/bolt/test/Inputs/stub.h @@ -6,5 +6,6 @@ int printf(const char *format, ...); void exit(int status); int puts(const char *s); +int rand(void); #endif diff --git a/bolt/test/Inputs/stub.c b/bolt/test/Inputs/stub.c --- a/bolt/test/Inputs/stub.c +++ b/bolt/test/Inputs/stub.c @@ -5,6 +5,7 @@ int printf(const char *format, ...) { return 0; } void exit(int status) {} int puts(const char *s) { return 0; } +int rand(void) { return 0; } void *__gxx_personality_v0; void *__cxa_allocate_exception; diff --git a/bolt/test/R_ABS.pic.lld.cpp b/bolt/test/R_ABS.pic.lld.cpp --- a/bolt/test/R_ABS.pic.lld.cpp +++ b/bolt/test/R_ABS.pic.lld.cpp @@ -2,7 +2,7 @@ * 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=lld + * RUN: %clang %cflags -fPIC -shared %s -o %t.so -Wl,-q -fuse-ld=lld * RUN: llvm-bolt %t.so -o %t.so.bolt -relocs */ diff --git a/bolt/test/X86/Inputs/avx512.c b/bolt/test/X86/Inputs/avx512.c deleted file mode 100644 --- a/bolt/test/X86/Inputs/avx512.c +++ /dev/null @@ -1,10 +0,0 @@ -void use_avx512() { - asm (".byte 0x62, 0xe2, 0xf5, 0x70, 0x2c, 0xda"); - asm("secondary_entry:"); -} - -int main() { - use_avx512(); - - return 0; -} diff --git a/bolt/test/X86/Inputs/avx512.s b/bolt/test/X86/Inputs/avx512.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/avx512.s @@ -0,0 +1,21 @@ +.globl use_avx512 +use_avx512: + pushq %rbp + movq %rsp, %rbp + vscalefpd {rz-sae}, %zmm2, %zmm17, %zmm19 +secondary_entry: + popq %rbp + retq + nopl (%rax) + +.globl main +main: + pushq %rbp + movq %rsp, %rbp + subq $16, %rsp + movl $0, -4(%rbp) + callq use_avx512 + xorl %eax, %eax + addq $16, %rsp + popq %rbp + retq diff --git a/bolt/test/X86/avx512-trap.test b/bolt/test/X86/avx512-trap.test --- a/bolt/test/X86/avx512-trap.test +++ b/bolt/test/X86/avx512-trap.test @@ -1,11 +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 %cflags %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 +RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-unknown -o %t.o \ +RUN: %S/Inputs/avx512.s +RUN: ld.lld %t.o -o %t -q +RUN: llvm-objdump -d --disassemble-symbols=use_avx512 %t | \ +RUN: FileCheck %s --check-prefix=CHECK-DIS-NO-TRAP + +RUN: llvm-bolt %t -trap-avx512=1 -o %t.bolt -lite=0 2>&1 | FileCheck %s +RUN: llvm-objdump -d --disassemble-symbols=use_avx512 %t.bolt | \ +RUN: FileCheck %s --check-prefix=CHECK-DIS + +RUN: llvm-bolt %t -trap-avx512=0 -o %t.bolt -lite=0 +RUN: llvm-objdump -d --disassemble-symbols=use_avx512 %t.bolt | \ +RUN: FileCheck %s --check-prefix=CHECK-DIS-NO-TRAP CHECK: BOLT-WARNING: 1 function will trap on entry diff --git a/bolt/test/X86/lit.local.cfg b/bolt/test/X86/lit.local.cfg --- a/bolt/test/X86/lit.local.cfg +++ b/bolt/test/X86/lit.local.cfg @@ -1,12 +1,7 @@ if not 'X86' in config.root.targets: config.unsupported = True -config.substitutions.insert( - 0, ('%cflags', - '%cflags --target=x86_64--pc-linux -nostdlib -fuse-ld=lld' - ' -Wl,--unresolved-symbols=ignore-all')) +flags = '--target=x86_64-pc-linux -nostdlib' -config.substitutions.insert( - 0, ('%cxxflags', - '%cxxflags --target=x86_64--pc-linux -nostdlib -fuse-ld=lld' - ' -Wl,--unresolved-symbols=ignore-all')) +config.substitutions.insert(0, ('%cflags', f'%cflags {flags}')) +config.substitutions.insert(0, ('%cxxflags', f'%cxxflags {flags}')) diff --git a/bolt/test/X86/relaxed-tailcall.test b/bolt/test/X86/relaxed-tailcall.test --- a/bolt/test/X86/relaxed-tailcall.test +++ b/bolt/test/X86/relaxed-tailcall.test @@ -1,6 +1,8 @@ # Check that tail calls can be 2 bytes in the output binary. -RUN: %clang %cflags %S/Inputs/relaxed_tc.s -o %t.exe -Wl,-q +RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-unknown -o %t.o \ +RUN: %S/Inputs/relaxed_tc.s +RUN: ld.lld %t.o -o %t.exe -q RUN: llvm-bolt %t.exe -relocs -o %t RUN: llvm-objdump -d --disassemble-symbols=foo %t | FileCheck %s diff --git a/bolt/test/bad-exe.test b/bolt/test/bad-exe.test --- a/bolt/test/bad-exe.test +++ b/bolt/test/bad-exe.test @@ -1,6 +1,6 @@ # 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/icf-jump-tables.c -g -o %t +RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -g -o %t RUN: llvm-objcopy --only-keep-debug %t %t.debuginfo RUN: not llvm-bolt %t.debuginfo -o /dev/null 2>&1 | FileCheck %s diff --git a/bolt/test/bolt-info.test b/bolt/test/bolt-info.test --- a/bolt/test/bolt-info.test +++ b/bolt/test/bolt-info.test @@ -1,5 +1,5 @@ # Check that the .bolt_info section is generated properly. -RUN: %clang %S/Inputs/icf-jump-tables.c -o %t +RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -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 diff --git a/bolt/test/lit.local.cfg b/bolt/test/lit.local.cfg new file mode 100644 --- /dev/null +++ b/bolt/test/lit.local.cfg @@ -0,0 +1,6 @@ +host_linux_triple = config.target_triple.split('-')[0]+'-linux' +common_linker_flags = '-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all' +flags = f'--target={host_linux_triple} {common_linker_flags}' + +config.substitutions.insert(0, ('%cflags', f'%cflags {flags}')) +config.substitutions.insert(0, ('%cxxflags', f'%cxxflags {flags}')) diff --git a/bolt/test/no-relocs.test b/bolt/test/no-relocs.test --- a/bolt/test/no-relocs.test +++ b/bolt/test/no-relocs.test @@ -1,6 +1,6 @@ # Verifies that input without relocations is rejected in relocs mode. -RUN: %clang %S/Inputs/icf-jump-tables.c -o %t +RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -o %t RUN: not llvm-bolt %t -o /dev/null -relocs 2>&1 | FileCheck %s CHECK: BOLT-ERROR: relocations against code are missing from the input file. diff --git a/bolt/test/pie.test b/bolt/test/pie.test --- a/bolt/test/pie.test +++ b/bolt/test/pie.test @@ -1,6 +1,6 @@ # Check that we do not reject position-independent executables (PIEs). -RUN: %clang -fPIC -pie %p/Inputs/jump_table_icp.cpp -o %t +RUN: %clang %cflags -fPIC -pie %p/Inputs/jump_table_icp.cpp -o %t RUN: llvm-bolt %t -o /dev/null 2>&1 | FileCheck %s CHECK: BOLT-INFO: shared object or position-independent executable detected diff --git a/bolt/test/re-optimize.test b/bolt/test/re-optimize.test --- a/bolt/test/re-optimize.test +++ b/bolt/test/re-optimize.test @@ -1,6 +1,6 @@ # Check that we detect re-optimization attempt. -RUN: %clang %S/Inputs/icf-jump-tables.c -o %t.exe +RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -o %t.exe RUN: llvm-bolt %t.exe -o %t 2>&1 > /dev/null RUN: not llvm-bolt %t -o %t.bolt 2>&1 | FileCheck %s diff --git a/bolt/test/shared-object.test b/bolt/test/shared-object.test --- a/bolt/test/shared-object.test +++ b/bolt/test/shared-object.test @@ -1,5 +1,5 @@ # Test that llvm-bolt processes *.so without a failure -RUN: %clang %S/Inputs/icf-jump-tables.c -o %t.so -shared -fPIC -Wl,--build-id +RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -o %t.so -shared -fPIC -Wl,--build-id RUN: llvm-bolt %t.so -o %t | FileCheck %s CHECK: patched build-id