[BOLT][test] Fix X86 tests

Differential Revision: https://reviews.llvm.org/D123133
This commit is contained in:
Vladislav Khmelevsky 2022-04-05 18:41:17 +03:00
parent 9fc45ca00a
commit 87a57aada3
18 changed files with 44 additions and 20 deletions

View File

@ -5,3 +5,8 @@ config.substitutions.insert(
0, ('%cflags',
'%cflags --target=aarch64-pc-linux -nostartfiles -nostdlib -fuse-ld=lld'
' -ffreestanding -Wl,--unresolved-symbols=ignore-all'))
config.substitutions.insert(
0, ('%cxxflags',
'%cxxflags --target=aarch64-pc-linux -nostartfiles -nostdlib -fuse-ld=lld'
' -ffreestanding -Wl,--unresolved-symbols=ignore-all'))

View File

@ -4,3 +4,10 @@ void *memcpy(void *dest, const void *src, unsigned long n) { return 0; }
void *memset(void *dest, int c, unsigned long n) { return 0; }
int printf(const char *format, ...) { return 0; }
void exit(int status) {}
void *__gxx_personality_v0;
void *__cxa_allocate_exception;
void *_ZTIi;
void *__cxa_throw;
void *__cxa_begin_catch;
void *__cxa_end_catch;

View File

@ -78,8 +78,10 @@ foo:
.uleb128 0x1
.LLSDACSE1:
.LLSDATT1:
.text
.globl main, function
main:
.globl _start, function
_start:
.cfi_startproc
ud2
.cfi_endproc

View File

@ -1,7 +1,7 @@
/**
* Test for asm-dump functionality.
*
* REQUIRES: system-linux
* REQUIRES: system-linux,bolt-runtime
*
* Compile the source
* RUN: %clang -fPIC %s -o %t.exe -Wl,-q
@ -59,7 +59,8 @@
* CHECK-FILE-NEXT: .size main, .-main
* CHECK-FILE: .section .rodata
*
* CHECK-REOPT: BOLT-INFO: 1 out of {{.*}} functions in the binary {{.*}} have non-empty execution profile
* CHECK-REOPT: BOLT-INFO: 1 out of {{.*}} functions in the binary {{.*}} have
* CHECK-REOPT: non-empty execution profile
*/
#include <stdio.h>
#include <string.h>

View File

@ -1,7 +1,7 @@
# 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: %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 && \

View File

@ -12,7 +12,7 @@
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
# RUN: %s -o %t.o
# RUN: link_fdata %s %t.o %t.fdata
# RUN: %clang %t.o -falign-labels -march=native -o %t.exe -Wl,-q
# RUN: %clang %cflags %t.o -falign-labels -march=native -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolted -data %t.fdata \
# RUN: -reorder-blocks=cache+ -reorder-functions=hfsort \

View File

@ -1,7 +1,8 @@
# Check that we handle GNU_args_size correctly.
# It is generated for throwing functions with LP that have parameters on stack.
RUN: %clangxx %cxxflags %p/Inputs/exc_args.s -o %t
RUN: %clang %cflags %p/../Inputs/stub.c -fPIC -pie -shared -o %t.so
RUN: %clangxx %cxxflags %p/Inputs/exc_args.s -o %t %t.so -Wl,-z,notext
RUN: llvm-bolt %t -o /dev/null -print-finalized -print-only=main | FileCheck %s
CHECK: Binary Function "main" after finalize-functions

View File

@ -5,7 +5,7 @@ RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
RUN: %S/Inputs/ft_to_noop.s -o %t.o
RUN: link_fdata %S/Inputs/ft_to_noop.s %t.o %t.fdata
RUN: llvm-strip --strip-unneeded %t.o
RUN: %clang %t.o -o %t.exe -Wl,-q
RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
RUN: llvm-bolt %t.exe -o %t -data %t.fdata \
RUN: -print-cfg -sequential-disassembly 2>&1 | FileCheck %s

View File

@ -1,9 +1,9 @@
# Make sure inlining from a unit with debug info into unit without
# debug info does not cause a crash.
RUN: %clangxx %S/Inputs/inlined.cpp -c -o %T/inlined.o
RUN: %clangxx %cxxflags %S/Inputs/inlined.cpp -c -o %T/inlined.o
RUN: %clangxx %cxxflags %S/Inputs/inlinee.cpp -c -o %T/inlinee.o -g
RUN: %clangxx %T/inlined.o %T/inlinee.o -o %t
RUN: %clangxx %cxxflags %T/inlined.o %T/inlinee.o -o %t
RUN: llvm-bolt %t -o %t.bolt -update-debug-sections -reorder-blocks=reverse \
RUN: -inline-small-functions -force-inline=main | FileCheck %s

View File

@ -1,6 +1,6 @@
# Tests the optimization of functions that just do a tail call in the beginning.
RUN: %clang -O2 %S/Inputs/jmp_opt{,2,3}.cpp -o %t
RUN: %clang %cflags -O2 %S/Inputs/jmp_opt{,2,3}.cpp -o %t
RUN: llvm-bolt -inline-small-functions %t -o %t.bolt
RUN: llvm-objdump -d %t.bolt --print-imm-hex | FileCheck %s

View File

@ -1,6 +1,6 @@
# Verifies that the extraction of DWARF line number information is correct.
RUN: %clangxx %S/Inputs/linenumber.cpp -g -o %t
RUN: %clangxx %cxxflags %S/Inputs/linenumber.cpp -g -o %t
RUN: llvm-bolt %t -o /dev/null -print-reordered -update-debug-sections \
RUN: -print-debug-info -reorder-blocks=reverse -sequential-disassembly 2>&1 \
RUN: | FileCheck %s

View File

@ -3,5 +3,10 @@ if not 'X86' in config.root.targets:
config.substitutions.insert(
0, ('%cflags',
'%cflags --target=x86_64--pc-linux -nostartfiles -nostdlib -fuse-ld=lld'
'%cflags --target=x86_64--pc-linux -nostdlib -fuse-ld=lld'
' -Wl,--unresolved-symbols=ignore-all'))
config.substitutions.insert(
0, ('%cxxflags',
'%cxxflags --target=x86_64--pc-linux -nostdlib -fuse-ld=lld'
' -Wl,--unresolved-symbols=ignore-all'))

View File

@ -6,8 +6,8 @@
# RUN: %s -o %t.o
# RUN: link_fdata %s %t.o %t.fdata
# RUN: llvm-strip --strip-unneeded %t.o
# RUN: %clang %t.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -relocs=1 -print-profile-stats -o /dev/null \
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -print-profile-stats -o /dev/null \
# RUN: -data %t.fdata | FileCheck %s
.text

View File

@ -1,6 +1,6 @@
# Check for the simplification of .rodata loads.
RUN: %clang %p/Inputs/rodata_simpl_loads.s -o %t.exe
RUN: %clang %cflags %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

View File

@ -1,7 +1,7 @@
# Test that 64 bit movq instructions with immediate operands
# that fit in 32 bits are shortened.
RUN: %clang %p/Inputs/asm_main.c %p/Inputs/shorten_mov.s -o %t.exe
RUN: %clang %cflags %p/Inputs/asm_main.c %p/Inputs/shorten_mov.s -o %t.exe
RUN: llvm-bolt %t.exe -o %t
RUN: llvm-objdump -d %t --print-imm-hex | FileCheck %s

View File

@ -1,6 +1,6 @@
# Check that llvm-bolt can rewrite static executable
RUN: %clang %S/Inputs/static_exe.s -static -o %t.exe -nostdlib
RUN: %clang %cflags %S/Inputs/static_exe.s -static -o %t.exe -nostdlib
RUN: llvm-bolt %t.exe -o %t |& FileCheck %s
CHECK: 1 out of 1 functions were overwritten

View File

@ -1,7 +1,7 @@
# Verifies that llvm-bolt recognizes tailcalls and mark them
# in control flow graph.
RUN: %clang %S/Inputs/tailcall.s -o %t.exe
RUN: %clang %cflags %S/Inputs/tailcall.s -o %t.exe
RUN: llvm-bolt %t.exe -o /dev/null -print-cfg 2>&1 | FileCheck %s
CHECK: Binary Function "foo"

View File

@ -1,6 +1,9 @@
# Check unreachable code elimination
RUN: %clangxx %cxxflags %p/Inputs/unreachable.s -o %t.exe
RUN: %clang %cflags %p/../Inputs/stub.c -fPIC -pie -shared -o %t.so
RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
RUN: %p/Inputs/unreachable.s -o %t.o
RUN: %clangxx %cxxflags %t.o -o %t.exe %t.so
RUN: llvm-bolt %t.exe -o %t \
RUN: -reorder-blocks=none -split-functions=1 -eliminate-unreachable \
RUN: -funcs=foo -use-gnu-stack -print-cfg -print-finalized \