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 @@ -5,3 +5,8 @@ 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')) 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 @@ -4,3 +4,10 @@ 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; diff --git a/bolt/test/X86/asm-dump.c b/bolt/test/X86/asm-dump.c --- a/bolt/test/X86/asm-dump.c +++ b/bolt/test/X86/asm-dump.c @@ -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 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,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 && \ diff --git a/bolt/test/X86/bug-reorder-bb-jrcxz.s b/bolt/test/X86/bug-reorder-bb-jrcxz.s --- a/bolt/test/X86/bug-reorder-bb-jrcxz.s +++ b/bolt/test/X86/bug-reorder-bb-jrcxz.s @@ -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 \ diff --git a/bolt/test/X86/exceptions-args.test b/bolt/test/X86/exceptions-args.test --- a/bolt/test/X86/exceptions-args.test +++ b/bolt/test/X86/exceptions-args.test @@ -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 diff --git a/bolt/test/X86/fallthrough-to-noop.test b/bolt/test/X86/fallthrough-to-noop.test --- a/bolt/test/X86/fallthrough-to-noop.test +++ b/bolt/test/X86/fallthrough-to-noop.test @@ -5,7 +5,7 @@ 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 diff --git a/bolt/test/X86/inlined-function-mixed.test b/bolt/test/X86/inlined-function-mixed.test --- a/bolt/test/X86/inlined-function-mixed.test +++ b/bolt/test/X86/inlined-function-mixed.test @@ -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 diff --git a/bolt/test/X86/jmp-optimization.test b/bolt/test/X86/jmp-optimization.test --- a/bolt/test/X86/jmp-optimization.test +++ b/bolt/test/X86/jmp-optimization.test @@ -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 diff --git a/bolt/test/X86/line-number.test b/bolt/test/X86/line-number.test --- a/bolt/test/X86/line-number.test +++ b/bolt/test/X86/line-number.test @@ -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 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 @@ -3,5 +3,10 @@ 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')) diff --git a/bolt/test/X86/no-output.test b/bolt/test/X86/no-output.test --- a/bolt/test/X86/no-output.test +++ b/bolt/test/X86/no-output.test @@ -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 diff --git a/bolt/test/X86/rodata-simpl-loads.test b/bolt/test/X86/rodata-simpl-loads.test --- a/bolt/test/X86/rodata-simpl-loads.test +++ b/bolt/test/X86/rodata-simpl-loads.test @@ -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 diff --git a/bolt/test/X86/shorten-mov.test b/bolt/test/X86/shorten-mov.test --- a/bolt/test/X86/shorten-mov.test +++ b/bolt/test/X86/shorten-mov.test @@ -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 diff --git a/bolt/test/X86/static-exe.test b/bolt/test/X86/static-exe.test --- a/bolt/test/X86/static-exe.test +++ b/bolt/test/X86/static-exe.test @@ -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 diff --git a/bolt/test/X86/tailcall.test b/bolt/test/X86/tailcall.test --- a/bolt/test/X86/tailcall.test +++ b/bolt/test/X86/tailcall.test @@ -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" diff --git a/bolt/test/X86/unreachable.test b/bolt/test/X86/unreachable.test --- a/bolt/test/X86/unreachable.test +++ b/bolt/test/X86/unreachable.test @@ -1,6 +1,11 @@ # Check unreachable code elimination -RUN: %clangxx %cxxflags %p/Inputs/unreachable.s -o %t.exe +XFAIL: * + +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 \