Commit 52d0f7bd by Daniel Santos Committed by Daniel Santos

PR testsuite/80759 Fix broken tests in ms-sysv.exp

2017-07-24  Daniel Santos  <daniel.santos@pobox.com>

	PR testsuite/80759
	* gcc.target/x86_64/abi/ms-sysv/do-test.S
	(ELFFN_BEGIN): Rename to FN_TYPE.
	(ELFFN_END): Rename to FN_SIZE.
	(ASMNAME): New macro.
	(FUNC): Rename to FUNC_BEGIN, use ASMNAME and use .globl instead of
	.global.
	(FUNC_END): Use ASMNAME.
	(test_data_save): Remove.
	(test_data_input): Likewise.
	(test_data_output: Likewise.
	(test_data_fn): Likewise.
	(test_data_retaddr): Likewise.
	(regs_to_mem): Make globals, use r10 instead of rax.
	(mem_to_regs): Likewise.
	(do_test_unaligned): Remove .cfi directives, remove pushf/popf, move
	body to ms-sysv.c.
	(do_test_aligned): Likewise.
	* gcc.target/x86_64/abi/ms-sysv/ms-sysv.c:
	Add dg-* directives.
	(PASTE_STR): New macro.
	(ASMNAME): Likewise.
	(LOAD_TEST_DATA_ADDR): Likewise.
	(TEST_DATA_OFFSET): Likewise.
	(do_test_body0): New C function.
	(do_test_body): New inline assembly routine.
	* gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp
	(runtest_ms_sysv): Modify.

From-SVN: r250489
parent 9cbc07cc
2017-07-24 Daniel Santos <daniel.santos@pobox.com>
PR testsuite/80759
* gcc.target/x86_64/abi/ms-sysv/do-test.S
(ELFFN_BEGIN): Rename to FN_TYPE.
(ELFFN_END): Rename to FN_SIZE.
(ASMNAME): New macro.
(FUNC): Rename to FUNC_BEGIN, use ASMNAME and use .globl instead of
.global.
(FUNC_END): Use ASMNAME.
(test_data_save): Remove.
(test_data_input): Likewise.
(test_data_output: Likewise.
(test_data_fn): Likewise.
(test_data_retaddr): Likewise.
(regs_to_mem): Make globals, use r10 instead of rax.
(mem_to_regs): Likewise.
(do_test_unaligned): Remove .cfi directives, remove pushf/popf, move
body to ms-sysv.c.
(do_test_aligned): Likewise.
* gcc.target/x86_64/abi/ms-sysv/ms-sysv.c:
Add dg-* directives.
(PASTE_STR): New macro.
(ASMNAME): Likewise.
(LOAD_TEST_DATA_ADDR): Likewise.
(TEST_DATA_OFFSET): Likewise.
(do_test_body0): New C function.
(do_test_body): New inline assembly routine.
* gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp
(runtest_ms_sysv): Modify.
2017-07-24 Michael Meissner <meissner@linux.vnet.ibm.com> 2017-07-24 Michael Meissner <meissner@linux.vnet.ibm.com>
* gcc.target/powerpc/pr65849-1.c: Delete, test no longer valid * gcc.target/powerpc/pr65849-1.c: Delete, test no longer valid
......
...@@ -23,141 +23,101 @@ a copy of the GCC Runtime Library Exception along with this program; ...@@ -23,141 +23,101 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
#ifdef __x86_64__ #if defined(__x86_64__) && defined(__SSE2__)
# ifdef __ELF__ /* These macros currently support GNU/Linux, Solaris and Darwin. */
# define ELFFN_BEGIN(fn) .type fn,@function
# define ELFFN_END(fn) .size fn,.-fn #ifdef __ELF__
# else # define FN_TYPE(fn) .type fn,@function
# define ELFFN_BEGIN(fn) # define FN_SIZE(fn) .size fn,.-fn
# define ELFFN_END(fn) #else
# endif # define FN_TYPE(fn)
# define FN_SIZE(fn)
# define FUNC(fn) \ #endif
.global fn; \
ELFFN_BEGIN(fn); \ #ifdef __USER_LABEL_PREFIX__
fn: # define ASMNAME2(prefix, name) prefix ## name
# define ASMNAME1(prefix, name) ASMNAME2(prefix, name)
#define FUNC_END(fn) ELFFN_END(fn) # define ASMNAME(name) ASMNAME1(__USER_LABEL_PREFIX__, name)
#else
# ifdef __AVX__ # define ASMNAME(name) name
# define MOVAPS vmovaps #endif
# else
# define MOVAPS movaps #define FUNC_BEGIN(fn) \
# endif .globl ASMNAME(fn); \
FN_TYPE (ASMNAME(fn)); \
/* TODO: Is there a cleaner way to provide these offsets? */ ASMNAME(fn):
.struct 0
test_data_save: #define FUNC_END(fn) FN_SIZE(ASMNAME(fn))
.struct test_data_save + 224 #ifdef __AVX__
test_data_input: # define MOVAPS vmovaps
#else
.struct test_data_save + 448 # define MOVAPS movaps
test_data_output: #endif
.struct test_data_save + 672
test_data_fn:
.struct test_data_save + 680
test_data_retaddr:
.text .text
regs_to_mem: FUNC_BEGIN(regs_to_mem)
MOVAPS %xmm6, (%rax) MOVAPS %xmm6, (%r10)
MOVAPS %xmm7, 0x10(%rax) MOVAPS %xmm7, 0x10(%r10)
MOVAPS %xmm8, 0x20(%rax) MOVAPS %xmm8, 0x20(%r10)
MOVAPS %xmm9, 0x30(%rax) MOVAPS %xmm9, 0x30(%r10)
MOVAPS %xmm10, 0x40(%rax) MOVAPS %xmm10, 0x40(%r10)
MOVAPS %xmm11, 0x50(%rax) MOVAPS %xmm11, 0x50(%r10)
MOVAPS %xmm12, 0x60(%rax) MOVAPS %xmm12, 0x60(%r10)
MOVAPS %xmm13, 0x70(%rax) MOVAPS %xmm13, 0x70(%r10)
MOVAPS %xmm14, 0x80(%rax) MOVAPS %xmm14, 0x80(%r10)
MOVAPS %xmm15, 0x90(%rax) MOVAPS %xmm15, 0x90(%r10)
mov %rsi, 0xa0(%rax) mov %rsi, 0xa0(%r10)
mov %rdi, 0xa8(%rax) mov %rdi, 0xa8(%r10)
mov %rbx, 0xb0(%rax) mov %rbx, 0xb0(%r10)
mov %rbp, 0xb8(%rax) mov %rbp, 0xb8(%r10)
mov %r12, 0xc0(%rax) mov %r12, 0xc0(%r10)
mov %r13, 0xc8(%rax) mov %r13, 0xc8(%r10)
mov %r14, 0xd0(%rax) mov %r14, 0xd0(%r10)
mov %r15, 0xd8(%rax) mov %r15, 0xd8(%r10)
retq retq
FUNC_END(regs_to_mem)
mem_to_regs:
MOVAPS (%rax), %xmm6 FUNC_BEGIN(mem_to_regs)
MOVAPS 0x10(%rax),%xmm7 MOVAPS (%r10), %xmm6
MOVAPS 0x20(%rax),%xmm8 MOVAPS 0x10(%r10),%xmm7
MOVAPS 0x30(%rax),%xmm9 MOVAPS 0x20(%r10),%xmm8
MOVAPS 0x40(%rax),%xmm10 MOVAPS 0x30(%r10),%xmm9
MOVAPS 0x50(%rax),%xmm11 MOVAPS 0x40(%r10),%xmm10
MOVAPS 0x60(%rax),%xmm12 MOVAPS 0x50(%r10),%xmm11
MOVAPS 0x70(%rax),%xmm13 MOVAPS 0x60(%r10),%xmm12
MOVAPS 0x80(%rax),%xmm14 MOVAPS 0x70(%r10),%xmm13
MOVAPS 0x90(%rax),%xmm15 MOVAPS 0x80(%r10),%xmm14
mov 0xa0(%rax),%rsi MOVAPS 0x90(%r10),%xmm15
mov 0xa8(%rax),%rdi mov 0xa0(%r10),%rsi
mov 0xb0(%rax),%rbx mov 0xa8(%r10),%rdi
mov 0xb8(%rax),%rbp mov 0xb0(%r10),%rbx
mov 0xc0(%rax),%r12 mov 0xb8(%r10),%rbp
mov 0xc8(%rax),%r13 mov 0xc0(%r10),%r12
mov 0xd0(%rax),%r14 mov 0xc8(%r10),%r13
mov 0xd8(%rax),%r15 mov 0xd0(%r10),%r14
mov 0xd8(%r10),%r15
retq retq
FUNC_END(mem_to_regs)
# NOTE: Not MT safe # NOTE: Not MT safe
FUNC(do_test_unaligned) FUNC_BEGIN(do_test_unaligned)
.cfi_startproc
# The below alignment checks are to verify correctness of the test # The below alignment checks are to verify correctness of the test
# its self. # its self.
# Verify that incoming stack is aligned + 8 # Verify that incoming stack is aligned + 8
pushf test $0xf, %rsp
test $0x8, %rsp je ASMNAME(do_test_body)
jne L0
int $3 # Stack not unaligned int $3 # Stack not unaligned
FUNC_END(do_test_unaligned)
FUNC(do_test_aligned) FUNC_BEGIN(do_test_aligned)
# Verify that incoming stack is aligned # Verify that incoming stack is aligned
pushf test $0x8, %rsp
test $0xf, %rsp jne ASMNAME(do_test_body)
je L0
int $3 # Stack not aligned int $3 # Stack not aligned
L0:
popf
# Save registers
lea test_data(%rip), %rax
call regs_to_mem
# Load register with random data
lea test_data + test_data_input(%rip), %rax
call mem_to_regs
# Save original return address
pop %rax
movq %rax, test_data + test_data_retaddr(%rip)
# Call the test function
call *test_data + test_data_fn(%rip)
# Restore the original return address
movq test_data + test_data_retaddr(%rip), %rcx
push %rcx
# Save test function return value and store resulting register values
push %rax
lea test_data + test_data_output(%rip), %rax
call regs_to_mem
# Restore registers
lea test_data(%rip), %rax
call mem_to_regs
pop %rax
retq
.cfi_endproc
FUNC_END(do_test_aligned) FUNC_END(do_test_aligned)
FUNC_END(do_test_unaligned)
#endif /* __x86_64__ */ #endif /* __x86_64__ */
...@@ -46,6 +46,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -46,6 +46,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
is then called. After the function returns, the value of all volatile is then called. After the function returns, the value of all volatile
registers is verified against the random data and then restored. */ registers is verified against the random data and then restored. */
/* { dg-do run } */
/* { dg-additional-sources "do-test.S" } */
/* { dg-additional-options "-Wall" } */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -58,8 +62,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -58,8 +62,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <errno.h> #include <errno.h>
#include <ctype.h> #include <ctype.h>
#ifndef __x86_64__ #if !defined(__x86_64__) || !defined(__SSE2__)
# error Test only valid on x86_64 # error Test only valid on x86_64 with -msse2
#endif #endif
enum reg_data_sets enum reg_data_sets
...@@ -144,6 +148,81 @@ static __attribute__((ms_abi)) long ...@@ -144,6 +148,81 @@ static __attribute__((ms_abi)) long
static int arbitrarily_fail; static int arbitrarily_fail;
static const char *argv0; static const char *argv0;
#define PASTE_STR2(a) #a
#define PASTE_STR1(a, b) PASTE_STR2(a ## b)
#define PASTE_STR(a, b) PASTE_STR1(a, b)
#ifdef __USER_LABEL_PREFIX__
# define ASMNAME(name) PASTE_STR(__USER_LABEL_PREFIX__, name)
#else
# define ASMNAME(name) #name
#endif
#ifdef __MACH__
# define LOAD_TEST_DATA_ADDR(dest) \
" mov " ASMNAME(test_data) "@GOTPCREL(%%rip), " dest "\n"
#else
# define LOAD_TEST_DATA_ADDR(dest) \
" lea " ASMNAME(test_data) "(%%rip), " dest "\n"
#endif
#define TEST_DATA_OFFSET(f) ((int)__builtin_offsetof(struct test_data, f))
void __attribute__((used))
do_test_body0 (void)
{
__asm__ ("\n"
" .globl " ASMNAME(do_test_body) "\n"
#ifdef __ELF__
" .type " ASMNAME(do_test_body) ",@function\n"
#endif
ASMNAME(do_test_body) ":\n"
" # rax, r10 and r11 are usable here.\n"
"\n"
" # Save registers.\n"
LOAD_TEST_DATA_ADDR("%%rax")
" lea %p0(%%rax), %%r10\n"
" call " ASMNAME(regs_to_mem) "\n"
"\n"
" # Load registers with random data.\n"
" lea %p1(%%rax), %%r10\n"
" call " ASMNAME(mem_to_regs) "\n"
"\n"
" # Pop and save original return address.\n"
" pop %%r10\n"
" mov %%r10, %p4(%%rax)\n"
"\n"
" # Call the test function, after which rcx, rdx and r8-11\n"
" # become usable.\n"
" lea %p3(%%rax), %%rax\n"
" call *(%%rax)\n"
"\n"
" # Store resulting register values.\n"
LOAD_TEST_DATA_ADDR("%%rcx")
" lea %p2(%%rcx), %%r10\n"
" call " ASMNAME(regs_to_mem) "\n"
"\n"
" # Push the original return address.\n"
" lea %p4(%%rcx), %%r10\n"
" push (%%r10)\n"
"\n"
" # Restore registers.\n"
" lea %p0(%%rcx), %%r10\n"
" call " ASMNAME(mem_to_regs) "\n"
"\n"
" retq\n"
#ifdef __ELF__
" .size " ASMNAME(do_test_body) ",.-" ASMNAME(do_test_body) "\n"
#endif
::
"i"(TEST_DATA_OFFSET(regdata[REG_SET_SAVE])),
"i"(TEST_DATA_OFFSET(regdata[REG_SET_INPUT])),
"i"(TEST_DATA_OFFSET(regdata[REG_SET_OUTPUT])),
"i"(TEST_DATA_OFFSET(fn)),
"i"(TEST_DATA_OFFSET(retaddr)) : "memory");
}
static void __attribute__((noinline)) static void __attribute__((noinline))
init_test (void *fn, const char *name, enum alignment_option alignment, init_test (void *fn, const char *name, enum alignment_option alignment,
enum shrink_wrap_option shrink_wrap, long ret_expected) enum shrink_wrap_option shrink_wrap, long ret_expected)
......
...@@ -56,52 +56,48 @@ proc host_supports_c++11 {} { ...@@ -56,52 +56,48 @@ proc host_supports_c++11 {} {
# Exit immediately if this isn't a native x86_64 target. # Exit immediately if this isn't a native x86_64 target.
if { (![istarget x86_64-*-*] && ![istarget i?86-*-*]) if { (![istarget x86_64-*-*] && ![istarget i?86-*-*])
|| ![is-effective-target lp64] || ![isnative] || ![is-effective-target lp64] || ![isnative]
|| ![host_supports_c++11] } then { || ![host_supports_c++11] } then {
unsupported "$subdir"
# Gate "unsupported" message return value of first runtest_file_p call.
if [runtest_file_p $runtests "$srcdir/$subdir/ms-sysv.c"] {
unsupported "$subdir"
}
return return
} }
global GCC_RUNTEST_PARALLELIZE_DIR
proc runtest_ms_sysv { cflags generator_args } { proc runtest_ms_sysv { cflags generator_args } {
global GCC_UNDER_TEST HOSTCXX HOSTCXXFLAGS tmpdir srcdir subdir \ global GCC_UNDER_TEST HOSTCXX HOSTCXXFLAGS tmpdir srcdir subdir \
parallel_dir next_test TEST_ALWAYS_FLAGS runtests
set objdir "$tmpdir/ms-sysv" set objdir "$tmpdir/ms-sysv"
set generator "$tmpdir/ms-sysv-generate.exe" set generator "$tmpdir/ms-sysv-generate.exe"
set generated_header "$objdir/ms-sysv-generated.h" set generated_header "$objdir/ms-sysv-generated.h"
set do_test_o "$objdir/do-test.o"
set ms_sysv_o "$objdir/ms-sysv.o"
set ms_sysv_exe "$objdir/ms-sysv.exe"
set status 0 set status 0
set warn_flags "-Wall" set warn_flags "-Wall"
set this_test $next_test
incr next_test
# Do parallelization here
if [catch {set fd [open "$parallel_dir/$this_test" \
[list RDWR CREAT EXCL]]} ] {
if { [lindex $::errorCode 1] eq "EEXIST" } then {
# Another job is running this test
return
} else {
error "Failed to open $parallel_dir/$this_test: $::errorCode"
set status 1
}
} else {
close $fd
}
# Detect when hard frame pointers are enabled (or required) so we know not # Detect when hard frame pointers are enabled (or required) so we know not
# to generate bp clobbers. # to generate bp clobbers.
if [regexp "^(.+ +| *)-(O0|fno-omit-frame-pointer|p|pg)( +.*)?$" \ if { [regexp "(^| )-(O0|fno-omit-frame-pointer|p|pg)( |$)" \
$cflags match] then { "$TEST_ALWAYS_FLAGS $cflags" match]
|| [istarget *-*-solaris*] } then {
set generator_args "$generator_args --omit-rbp-clobbers" set generator_args "$generator_args --omit-rbp-clobbers"
} }
set descr "$subdir CFLAGS=\"$cflags\" generator_args=\"$generator_args\"" # Add all other flags
verbose "$tmpdir: Running test $descr" 1 set escaped_generator_args [regsub -all " " $generator_args "\\ "]
set cflags "$cflags\"-DGEN_ARGS=$escaped_generator_args\""
gcc_parallel_test_enable 1
if ![runtest_file_p $runtests "$srcdir/$subdir/ms-sysv.c"] then {
return
}
#verbose "runtest_ms_sysv $cflags" 0
# Make sure there's no previous header file so that we can't accidentally
# pass if generation fails.
file delete -force $generated_header
# Cleanup any previous test in objdir # Cleanup any previous test in objdir
file delete -force $objdir file delete -force $objdir
...@@ -109,18 +105,16 @@ proc runtest_ms_sysv { cflags generator_args } { ...@@ -109,18 +105,16 @@ proc runtest_ms_sysv { cflags generator_args } {
# Build the generator (only needs to be done once). # Build the generator (only needs to be done once).
set src "$srcdir/$subdir/gen.cc" set src "$srcdir/$subdir/gen.cc"
if { $status == 0 } then { if { (![file exists "$generator"]) || ([file mtime "$generator"]
if { (![file exists "$generator"]) || ([file mtime "$generator"] < [file mtime "$src"]) } {
< [file mtime "$src"]) } { # Temporarily switch to the environment for the host compiler.
# Temporarily switch to the environment for the host compiler. restore_ld_library_path_env_vars
restore_ld_library_path_env_vars set cxx "$HOSTCXX $HOSTCXXFLAGS $TEST_ALWAYS_FLAGS $warn_flags -std=c++11"
set cxx "$HOSTCXX $HOSTCXXFLAGS $warn_flags -std=c++11" set status [remote_exec host "$cxx -o $generator $src"]
set status [remote_exec host "$cxx -o $generator $src"] set status [lindex $status 0]
set status [lindex $status 0] set_ld_library_path_env_vars
set_ld_library_path_env_vars if { $status != 0 } then {
if { $status != 0 } then { warning "Could not build $subdir generator"
warning "Could not build $subdir generator"
}
} }
} }
...@@ -133,75 +127,26 @@ proc runtest_ms_sysv { cflags generator_args } { ...@@ -133,75 +127,26 @@ proc runtest_ms_sysv { cflags generator_args } {
} }
} }
set cc "$GCC_UNDER_TEST -I$objdir -I$srcdir/$subdir $cflags $warn_flags" gcc_parallel_test_enable 0
dg-runtest $srcdir/$subdir/ms-sysv.c "$cflags" "-I$objdir -I$srcdir/$subdir $warn_flags"
# Assemble do-test.S gcc_parallel_test_enable 1
set src "$srcdir/$subdir/do-test.S"
if { $status == 0 } then {
set status [remote_exec build "$cc -c -o $do_test_o $src"]
set status [lindex $status 0]
if { $status != 0 } then {
warning "Could not assemble $src"
}
}
# Build ms-sysv.c
set src "$srcdir/$subdir/ms-sysv.c"
if { $status == 0 } then {
set status [remote_exec build "$cc -c -o $ms_sysv_o $src" "" "" "" 1200]
set status [lindex $status 0]
if { $status != 0 } then {
warning "Could not build $src."
}
}
# Link
if { $status == 0 } then {
set status [remote_exec build "$cc -o $ms_sysv_exe $ms_sysv_o $do_test_o"]
set status [lindex $status 0]
if { $status != 0 } then {
warning "Link failed."
}
}
# Execute
if { $status == 0 } then {
set status [remote_exec build "$ms_sysv_exe"]
set status [lindex $status 0]
}
if { $status != 0 } then {
fail $descr
} else {
pass $descr
}
} }
dg-init dg-init
# Setup parallelization # Standard test parameters.
set next_test 0 set gen_pcount_opts [list "-p0" "-p1" "-p5"]
set parallel_dir "$env(GCC_RUNTEST_PARALLELIZE_DIR)/abi-ms-sysv" set base_cflags_arr [list " -O2 " " -O0 -g3 "]
file mkdir "$env(GCC_RUNTEST_PARALLELIZE_DIR)"
file mkdir "$parallel_dir"
if { ![file isdirectory "$parallel_dir"] } then {
error "Failed to create directory $parallel_dir: $::errorCode"
return
}
set gen_opts "-p0-5" foreach gen_opts $gen_pcount_opts {
set all_options [list "-O2" "-O0 -g3"] foreach cflags $base_cflags_arr {
# Run without -mcall-ms2sysv-xlogues always
runtest_ms_sysv "$cflags" "$gen_opts"
# Run without -mcall-ms2sysv-xlogues always # Skip unsupported -mcall-ms2sysv-xlogues on Windows
foreach opt $all_options { if { ![istarget *-*-cygwin*] && ![istarget *-*-mingw*] } {
runtest_ms_sysv "$opt" "$gen_opts" runtest_ms_sysv "-mcall-ms2sysv-xlogues$cflags" "$gen_opts"
} }
# Skip -mcall-ms2sysv-xlogues on Windows (not supported)
if { ![istarget *-*-cygwin*] && ![istarget *-*-mingw*] } {
foreach opt $all_options {
runtest_ms_sysv "-mcall-ms2sysv-xlogues $opt" "$gen_opts"
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment