From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35484 invoked by alias); 2 Jul 2017 05:10:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 35428 invoked by uid 89); 2 Jul 2017 05:10:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_MANYTO,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=gate, Assemble, $fd, resulted X-HELO: sasl.smtp.pobox.com Received: from pb-smtp1.pobox.com (HELO sasl.smtp.pobox.com) (64.147.108.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 02 Jul 2017 05:09:59 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id BA129776AB; Sun, 2 Jul 2017 01:09:57 -0400 (EDT) Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id B34FE776AA; Sun, 2 Jul 2017 01:09:57 -0400 (EDT) Received: from localhost.localdomain (unknown [76.215.41.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 85698776A7; Sun, 2 Jul 2017 01:09:56 -0400 (EDT) From: Daniel Santos To: gcc-patches , Uros Bizjak , Jan Hubicka , Iain Sandoe , Ian Lance Taylor , Mike Stump , Rainer Orth Cc: Bernd Edlinger Subject: [PATCH 1/2] [testsuite] PR80759 fix tests on Solaris and Darwin Date: Sun, 02 Jul 2017 05:10:00 -0000 Message-Id: <20170702051503.7572-1-daniel.santos@pobox.com> In-Reply-To: <57df17f5-1714-a618-30a9-086c83ee7623@pobox.com> References: <57df17f5-1714-a618-30a9-086c83ee7623@pobox.com> X-Pobox-Relay-ID: B0D9E086-5EE4-11E7-A87F-EFB41968708C-06139138!pb-smtp1.pobox.com X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00026.txt.bz2 The ms-sysv.exp tests were failing on Solaris and Darwin targets. In addition, a number of other problems have been identified. * Assembly failed on Solaris and Darwin when not using gas due to use of .cfi directives and .struct. * Tests were failing on Solaris due to hard frame pointer being always enabled on that platform and and not passing --omit-rbp-clobbers to the code generator. * Manual compilation (via remote_exec as opposed to dg-runtest, et. al.) was missing TEST_ALWAYS_FLAGS, resulting in color codes in log files. It was also missing -m64 in some cases where it was needed. * When built with make -j48 on an unsupported triplet, the "test unsupported" message appeared 48 times in the log (it appears that several other tests do this as well). * Using hard-coded offsets in do-tests.S is ugly. This is fixed by moving some code into inline assembly in ms-sysv.c. * Custom parallelization code broke when running make without -j * Accessing the test_data global from assembly requires(?) use of global offset table on Darwin. This patch corrects all of these problems. The custom parallelization code has been removed and replaced with calls to procs in gcc's standard testing framework: gcc_parallel_test_enable, runtest_file_p and dg-runtest. This results in much poorer parallelization, which I hope to address in a future patch, but has little effect when built without checking enabled. Previously, each test job compiled and executed around 20k individual tests. This high number resulted in test jobs far exceeding the default 5 minute timeout for remote_/local_exec when gcc was built with --enable-checking=rtl. This has been resolved by splitting the tests out to a maximum of around 3500 tests per job. Signed-off-by: Daniel Santos --- .../gcc.target/x86_64/abi/ms-sysv/do-test.S | 200 +++++++++------------ .../gcc.target/x86_64/abi/ms-sysv/ms-sysv.c | 83 ++++++++- .../gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp | 153 +++++----------- 3 files changed, 210 insertions(+), 226 deletions(-) diff --git a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S index 1395235fd1e..ffe011bcc68 100644 --- a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S +++ b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S @@ -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 . */ -#ifdef __x86_64__ - -# ifdef __ELF__ -# define ELFFN_BEGIN(fn) .type fn,@function -# define ELFFN_END(fn) .size fn,.-fn -# else -# define ELFFN_BEGIN(fn) -# define ELFFN_END(fn) -# endif - -# define FUNC(fn) \ - .global fn; \ - ELFFN_BEGIN(fn); \ -fn: - -#define FUNC_END(fn) ELFFN_END(fn) - -# ifdef __AVX__ -# define MOVAPS vmovaps -# else -# define MOVAPS movaps -# endif - -/* TODO: Is there a cleaner way to provide these offsets? */ - .struct 0 -test_data_save: - - .struct test_data_save + 224 -test_data_input: - - .struct test_data_save + 448 -test_data_output: - - .struct test_data_save + 672 -test_data_fn: - - .struct test_data_save + 680 -test_data_retaddr: +#if defined(__x86_64__) && defined(__SSE2__) + +/* These macros currently support GNU/Linux, Solaris and Darwin. */ + +#ifdef __ELF__ +# define FN_TYPE(fn) .type fn,@function +# define FN_SIZE(fn) .size fn,.-fn +#else +# define FN_TYPE(fn) +# define FN_SIZE(fn) +#endif + +#ifdef __USER_LABEL_PREFIX__ +# define ASMNAME2(prefix, name) prefix ## name +# define ASMNAME1(prefix, name) ASMNAME2(prefix, name) +# define ASMNAME(name) ASMNAME1(__USER_LABEL_PREFIX__, name) +#else +# define ASMNAME(name) name +#endif + +#define FUNC_BEGIN(fn) \ + .globl ASMNAME(fn); \ + FN_TYPE (ASMNAME(fn)); \ +ASMNAME(fn): + +#define FUNC_END(fn) FN_SIZE(ASMNAME(fn)) + +#ifdef __AVX__ +# define MOVAPS vmovaps +#else +# define MOVAPS movaps +#endif .text -regs_to_mem: - MOVAPS %xmm6, (%rax) - MOVAPS %xmm7, 0x10(%rax) - MOVAPS %xmm8, 0x20(%rax) - MOVAPS %xmm9, 0x30(%rax) - MOVAPS %xmm10, 0x40(%rax) - MOVAPS %xmm11, 0x50(%rax) - MOVAPS %xmm12, 0x60(%rax) - MOVAPS %xmm13, 0x70(%rax) - MOVAPS %xmm14, 0x80(%rax) - MOVAPS %xmm15, 0x90(%rax) - mov %rsi, 0xa0(%rax) - mov %rdi, 0xa8(%rax) - mov %rbx, 0xb0(%rax) - mov %rbp, 0xb8(%rax) - mov %r12, 0xc0(%rax) - mov %r13, 0xc8(%rax) - mov %r14, 0xd0(%rax) - mov %r15, 0xd8(%rax) +FUNC_BEGIN(regs_to_mem) + MOVAPS %xmm6, (%r10) + MOVAPS %xmm7, 0x10(%r10) + MOVAPS %xmm8, 0x20(%r10) + MOVAPS %xmm9, 0x30(%r10) + MOVAPS %xmm10, 0x40(%r10) + MOVAPS %xmm11, 0x50(%r10) + MOVAPS %xmm12, 0x60(%r10) + MOVAPS %xmm13, 0x70(%r10) + MOVAPS %xmm14, 0x80(%r10) + MOVAPS %xmm15, 0x90(%r10) + mov %rsi, 0xa0(%r10) + mov %rdi, 0xa8(%r10) + mov %rbx, 0xb0(%r10) + mov %rbp, 0xb8(%r10) + mov %r12, 0xc0(%r10) + mov %r13, 0xc8(%r10) + mov %r14, 0xd0(%r10) + mov %r15, 0xd8(%r10) retq - -mem_to_regs: - MOVAPS (%rax), %xmm6 - MOVAPS 0x10(%rax),%xmm7 - MOVAPS 0x20(%rax),%xmm8 - MOVAPS 0x30(%rax),%xmm9 - MOVAPS 0x40(%rax),%xmm10 - MOVAPS 0x50(%rax),%xmm11 - MOVAPS 0x60(%rax),%xmm12 - MOVAPS 0x70(%rax),%xmm13 - MOVAPS 0x80(%rax),%xmm14 - MOVAPS 0x90(%rax),%xmm15 - mov 0xa0(%rax),%rsi - mov 0xa8(%rax),%rdi - mov 0xb0(%rax),%rbx - mov 0xb8(%rax),%rbp - mov 0xc0(%rax),%r12 - mov 0xc8(%rax),%r13 - mov 0xd0(%rax),%r14 - mov 0xd8(%rax),%r15 +FUNC_END(regs_to_mem) + +FUNC_BEGIN(mem_to_regs) + MOVAPS (%r10), %xmm6 + MOVAPS 0x10(%r10),%xmm7 + MOVAPS 0x20(%r10),%xmm8 + MOVAPS 0x30(%r10),%xmm9 + MOVAPS 0x40(%r10),%xmm10 + MOVAPS 0x50(%r10),%xmm11 + MOVAPS 0x60(%r10),%xmm12 + MOVAPS 0x70(%r10),%xmm13 + MOVAPS 0x80(%r10),%xmm14 + MOVAPS 0x90(%r10),%xmm15 + mov 0xa0(%r10),%rsi + mov 0xa8(%r10),%rdi + mov 0xb0(%r10),%rbx + mov 0xb8(%r10),%rbp + mov 0xc0(%r10),%r12 + mov 0xc8(%r10),%r13 + mov 0xd0(%r10),%r14 + mov 0xd8(%r10),%r15 retq +FUNC_END(mem_to_regs) # NOTE: Not MT safe -FUNC(do_test_unaligned) - .cfi_startproc +FUNC_BEGIN(do_test_unaligned) # The below alignment checks are to verify correctness of the test # its self. # Verify that incoming stack is aligned + 8 - pushf - test $0x8, %rsp - jne L0 + test $0xf, %rsp + je ASMNAME(do_test_body) 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 - pushf - test $0xf, %rsp - je L0 + test $0x8, %rsp + jne ASMNAME(do_test_body) 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_unaligned) #endif /* __x86_64__ */ diff --git a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c index 2a011f5103d..caf9e6b5deb 100644 --- a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c +++ b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c @@ -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 registers is verified against the random data and then restored. */ +/* { dg-do run } */ +/* { dg-additional-sources "do-test.S" } */ +/* { dg-additional-options "-Wall" } */ + #include #include #include @@ -58,8 +62,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include #include -#ifndef __x86_64__ -# error Test only valid on x86_64 +#if !defined(__x86_64__) || !defined(__SSE2__) +# error Test only valid on x86_64 with -msse2 #endif enum reg_data_sets @@ -144,6 +148,81 @@ static __attribute__((ms_abi)) long static int arbitrarily_fail; 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)) init_test (void *fn, const char *name, enum alignment_option alignment, enum shrink_wrap_option shrink_wrap, long ret_expected) diff --git a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp index 26777e0b59f..87f81690bc7 100644 --- a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp +++ b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp @@ -56,52 +56,48 @@ proc host_supports_c++11 {} { # Exit immediately if this isn't a native x86_64 target. if { (![istarget x86_64-*-*] && ![istarget i?86-*-*]) - || ![is-effective-target lp64] || ![isnative] - || ![host_supports_c++11] } then { - unsupported "$subdir" + || ![is-effective-target lp64] || ![isnative] + || ![host_supports_c++11] } then { + + # Gate "unsupported" message return value of first runtest_file_p call. + if [runtest_file_p $runtests "$srcdir/$subdir/ms-sysv.c"] { + unsupported "$subdir" + } return } -global GCC_RUNTEST_PARALLELIZE_DIR - proc runtest_ms_sysv { cflags generator_args } { global GCC_UNDER_TEST HOSTCXX HOSTCXXFLAGS tmpdir srcdir subdir \ - parallel_dir next_test + TEST_ALWAYS_FLAGS runtests set objdir "$tmpdir/ms-sysv" set generator "$tmpdir/ms-sysv-generate.exe" 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 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 # to generate bp clobbers. - if [regexp "^(.+ +| *)-(O0|fno-omit-frame-pointer|p|pg)( +.*)?$" \ - $cflags match] then { + if { [regexp "(^| )-(O0|fno-omit-frame-pointer|p|pg)( |$)" \ + "$TEST_ALWAYS_FLAGS $cflags" match] + || [istarget *-*-solaris*] } then { set generator_args "$generator_args --omit-rbp-clobbers" } - set descr "$subdir CFLAGS=\"$cflags\" generator_args=\"$generator_args\"" - verbose "$tmpdir: Running test $descr" 1 + # Add all other flags + 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 file delete -force $objdir @@ -109,18 +105,16 @@ proc runtest_ms_sysv { cflags generator_args } { # Build the generator (only needs to be done once). set src "$srcdir/$subdir/gen.cc" - if { $status == 0 } then { - if { (![file exists "$generator"]) || ([file mtime "$generator"] - < [file mtime "$src"]) } { - # Temporarily switch to the environment for the host compiler. - restore_ld_library_path_env_vars - set cxx "$HOSTCXX $HOSTCXXFLAGS $warn_flags -std=c++11" - set status [remote_exec host "$cxx -o $generator $src"] - set status [lindex $status 0] - set_ld_library_path_env_vars - if { $status != 0 } then { - warning "Could not build $subdir generator" - } + if { (![file exists "$generator"]) || ([file mtime "$generator"] + < [file mtime "$src"]) } { + # Temporarily switch to the environment for the host compiler. + restore_ld_library_path_env_vars + set cxx "$HOSTCXX $HOSTCXXFLAGS $TEST_ALWAYS_FLAGS $warn_flags -std=c++11" + set status [remote_exec host "$cxx -o $generator $src"] + set status [lindex $status 0] + set_ld_library_path_env_vars + if { $status != 0 } then { + warning "Could not build $subdir generator" } } @@ -133,75 +127,26 @@ proc runtest_ms_sysv { cflags generator_args } { } } - set cc "$GCC_UNDER_TEST -I$objdir -I$srcdir/$subdir $cflags $warn_flags" - - # Assemble do-test.S - 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 - } + gcc_parallel_test_enable 0 + dg-runtest $srcdir/$subdir/ms-sysv.c "$cflags" "-I$objdir -I$srcdir/$subdir $warn_flags" + gcc_parallel_test_enable 1 } dg-init -# Setup parallelization -set next_test 0 -set parallel_dir "$env(GCC_RUNTEST_PARALLELIZE_DIR)/abi-ms-sysv" -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 -} +# Standard test parameters. +set gen_pcount_opts [list "-p0" "-p1" "-p5"] +set base_cflags_arr [list " -O2 " " -O0 -g3 "] -set gen_opts "-p0-5" -set all_options [list "-O2" "-O0 -g3"] +foreach gen_opts $gen_pcount_opts { + foreach cflags $base_cflags_arr { + # Run without -mcall-ms2sysv-xlogues always + runtest_ms_sysv "$cflags" "$gen_opts" -# Run without -mcall-ms2sysv-xlogues always -foreach opt $all_options { - runtest_ms_sysv "$opt" "$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" + # Skip unsupported -mcall-ms2sysv-xlogues on Windows + if { ![istarget *-*-cygwin*] && ![istarget *-*-mingw*] } { + runtest_ms_sysv "-mcall-ms2sysv-xlogues$cflags" "$gen_opts" + } } } -- 2.11.0