mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 14:20:17 +00:00
[BOLT][TEST] Fix testing on macos
- Fix common (arch-independent) tests to explicitly target -linux triple. - Override the triple inside arch-specific tests. - Add cflags to common tests. - Update individual tests. - Expand pipe stderr `|&` shorthand. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D125548
This commit is contained in:
parent
2f04e703bf
commit
da766cea56
@ -6,7 +6,7 @@ RUN: yaml2obj %p/Inputs/go_dwarf.yaml &> %t.exe
|
||||
RUN: llvm-bolt %t.exe -o %t.bolt -update-debug-sections
|
||||
|
||||
# Check the original binary values.
|
||||
RUN: llvm-dwarfdump -debug-info %t.exe |& \
|
||||
RUN: llvm-dwarfdump -debug-info %t.exe 2>&1 | \
|
||||
RUN: FileCheck %s -check-prefix=CHECKORIG
|
||||
|
||||
CHECKORIG: DW_TAG_compile_unit
|
||||
@ -30,7 +30,7 @@ CHECKORIG-NEXT: DW_AT_high_pc (0x0000000000000684)
|
||||
|
||||
|
||||
# Check the bolted binary.
|
||||
RUN: llvm-dwarfdump -debug-info %t.bolt |& FileCheck %s
|
||||
RUN: llvm-dwarfdump -debug-info %t.bolt 2>&1 | FileCheck %s
|
||||
|
||||
CHECK: DW_TAG_compile_unit
|
||||
CHECK-NEXT: DW_AT_producer
|
||||
|
@ -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}'))
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "stub.h"
|
||||
|
||||
int total = 0;
|
||||
|
||||
|
@ -5,6 +5,7 @@ void *memset(void *dest, int c, unsigned long n) { return 0; }
|
||||
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;
|
||||
|
@ -6,5 +6,6 @@ void *memset(void *dest, int c, unsigned long n);
|
||||
int printf(const char *format, ...);
|
||||
void exit(int status);
|
||||
int puts(const char *s);
|
||||
int rand(void);
|
||||
|
||||
#endif
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
void use_avx512() {
|
||||
asm (".byte 0x62, 0xe2, 0xf5, 0x70, 0x2c, 0xda");
|
||||
asm("secondary_entry:");
|
||||
}
|
||||
|
||||
int main() {
|
||||
use_avx512();
|
||||
|
||||
return 0;
|
||||
}
|
21
bolt/test/X86/Inputs/avx512.s
Normal file
21
bolt/test/X86/Inputs/avx512.s
Normal file
@ -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
|
@ -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
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Check llvm-bolt processes binaries compiled from sources that use indirect goto.
|
||||
RUN: %clang %cflags -no-pie %S/Inputs/indirect_goto.c -Wl,-q -o %t
|
||||
RUN: llvm-bolt %t -o /dev/null -relocs=1 -print-cfg -print-only=main -strict \
|
||||
RUN: |& FileCheck %s
|
||||
RUN: 2>&1 | FileCheck %s
|
||||
|
||||
# Check that all possible destinations are included as successors.
|
||||
CHECK: jmpq *%rax # UNKNOWN CONTROL FLOW
|
||||
|
@ -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}'))
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Check that llvm-bolt can rewrite static executable
|
||||
|
||||
RUN: %clang %cflags %S/Inputs/static_exe.s -static -o %t.exe -nostdlib
|
||||
RUN: llvm-bolt %t.exe -o %t |& FileCheck %s
|
||||
RUN: llvm-bolt %t.exe -o %t 2>&1 | FileCheck %s
|
||||
|
||||
CHECK: 1 out of 1 functions were overwritten
|
||||
|
@ -1,7 +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/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 |& FileCheck %s
|
||||
RUN: not llvm-bolt %t.debuginfo -o /dev/null 2>&1 | FileCheck %s
|
||||
|
||||
CHECK: input binary is not a valid ELF executable
|
||||
|
@ -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
|
||||
|
@ -1,6 +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
|
||||
RUN: not llvm-bolt %t -o %t.bolt -data %t 2>&1 | FileCheck %s
|
||||
|
||||
CHECK: no valid profile data found
|
||||
|
6
bolt/test/lit.local.cfg
Normal file
6
bolt/test/lit.local.cfg
Normal file
@ -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}'))
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user