From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76639 invoked by alias); 19 May 2017 23:22:50 -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 76625 invoked by uid 89); 19 May 2017 23:22:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=that, lean, fed X-HELO: sasl.smtp.pobox.com Received: from pb-smtp2.pobox.com (HELO sasl.smtp.pobox.com) (64.147.108.71) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 May 2017 23:22:47 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 712C78E821; Fri, 19 May 2017 19:22:48 -0400 (EDT) Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 6A4088E820; Fri, 19 May 2017 19:22:48 -0400 (EDT) Received: from [192.168.1.4] (unknown [76.215.41.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id A7AFB8E81F; Fri, 19 May 2017 19:22:47 -0400 (EDT) Subject: Re: [PATCH 2/2] [testsuite] PR 80759 Remove gas extensions from do-test.S, fix other problems To: Rainer Orth References: <3c867dc8-7d4a-ae82-c875-d03ff6d88776@pobox.com> <20170519063418.7836-2-daniel.santos@pobox.com> Cc: gcc-patches , Bernd Edlinger From: Daniel Santos Message-ID: <22cd31d5-26ac-e7b8-3f7b-dba0b65e8206@pobox.com> Date: Sat, 20 May 2017 00:38:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pobox-Relay-ID: 11EE9172-3CEA-11E7-ACB3-61520C78B957-06139138!pb-smtp2.pobox.com X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg01622.txt.bz2 Thanks you for your assistance Rainer! On 05/19/2017 04:03 AM, Rainer Orth wrote: > unfortunately, it still doesn't, as explained in the PR. The multilib > support is still wrong/non-existant. I guess I thought for some reason that would magically appear in TEST_ALWAYS_FLAGS. :) I've explicitly added it for now, but I haven't yet found where -m64 gets fed in the normal flow of things and I would rather know I'm doing things as closely as possible to how the rest if the test harness does it. >> (I have SVN write privs now, so I can even commit it myself). > Please always include ChangeLog entries with your patch submissions so > one can easily see what you've change > (cf. https://gcc.gnu.org/contribute.html). > > Thanks. > Rainer I hate when I forget that! I'll be sure to remember when I resubmit. >> Use of .struct in do_test.S causes breakages when gas isn't the >> assembler (e.g., Solaris). I also wasn't including TEST_ALWAYS_FLAGS in >> my CFLAGS resulting in super-ugly log files. Finally, this patch >> eliminates spam of "test unsupported" (limiting it to one printing). >> >> Signed-off-by: Daniel Santos >> --- >> .../gcc.target/x86_64/abi/ms-sysv/do-test.S | 26 +++++----------------- >> .../gcc.target/x86_64/abi/ms-sysv/ms-sysv.c | 7 ++++++ >> .../gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp | 24 ++++++++++++-------- >> 3 files changed, 27 insertions(+), 30 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..967eb959fbc 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 >> @@ -46,22 +46,6 @@ fn: >> # 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: >> - >> .text >> >> regs_to_mem: >> @@ -132,23 +116,23 @@ L0: >> call regs_to_mem >> >> # Load register with random data >> - lea test_data + test_data_input(%rip), %rax >> + lea test_data + 224(%rip), %rax >> call mem_to_regs >> >> # Save original return address >> pop %rax >> - movq %rax, test_data + test_data_retaddr(%rip) >> + movq %rax, test_data + 680(%rip) >> >> # Call the test function >> - call *test_data + test_data_fn(%rip) >> + call *test_data + 672(%rip) >> >> # Restore the original return address >> - movq test_data + test_data_retaddr(%rip), %rcx >> + movq test_data + 680(%rip), %rcx >> push %rcx >> >> # Save test function return value and store resulting register values >> push %rax >> - lea test_data + test_data_output(%rip), %rax >> + lea test_data + 448(%rip), %rax >> call regs_to_mem >> >> # Restore registers >> 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..7cec312c386 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 >> @@ -346,6 +346,13 @@ int main (int argc, char *argv[]) >> assert (!((long)&test_data.regdata[REG_SET_INPUT] & 15)); >> assert (!((long)&test_data.regdata[REG_SET_OUTPUT] & 15)); >> >> + /* Verify offsets hard-coded into assembly. */ >> + assert (__builtin_offsetof (struct test_data, regdata[REG_SET_SAVE]) == 0); >> + assert (__builtin_offsetof (struct test_data, regdata[REG_SET_INPUT]) == 224); >> + assert (__builtin_offsetof (struct test_data, regdata[REG_SET_OUTPUT]) == 448); >> + assert (__builtin_offsetof (struct test_data, fn) == 672); >> + assert (__builtin_offsetof (struct test_data, retaddr) == 680); >> + >> while ((c = getopt (argc, argv, "s:f")) != -1) >> { >> switch (c) > while .struct is a gas extension and doesn't work with the Solaris/x86 > /bin/as, having the same (mostly unexplained) constants hardcoded in two > places isn't exactly helpful. I'd suggest moving them to (say) > ms-sysv.h and include that from both do-test.S (which is preprocessed > assembler after all) and ms-sysv.c. > > Rainer Well, I don't have an ms-sysv.h, but I suppose I can add one. I'm starting to lean more towards the idea of plucking out the portion of asm that uses these offsets, moving that to an inline asm function and having the code in do-test.S just jmp to it. I wish there was some sort of "naked" attribute for x86 since I'm not well versed in every way that the compiler can change it in a way that wouldn't be friendly. void __attribute__((optimize ("-O0 -fno-split-stack"))) do_test_body (void) { __asm__ __volatile__ ( "# Save registers\n" " lea %0, %%rax\n" " call regs_to_mem\n" "\n" " # Load registers with random data\n" " lea %1, %%rax\n" " call mem_to_regs\n" "\n" " # Save original return address\n" " pop %%rax\n" " movq %%rax, %4\n" "\n" " # Call the test function\n" " call *%3\n" "\n" " # Restore the original return address\n" " movq %4, %%rcx\n" " push %%rcx\n" "\n" " # Save test function return value and store resulting register values\n" " push %%rax\n" " lea %2, %%rax\n" " call regs_to_mem\n" "\n" " # Restore registers\n" " lea %0, %%rax\n" " call mem_to_regs\n" " pop %%rax\n" " retq\n\t" FUNC_END("do_test_unaligned") FUNC_END("do_test_aligned") :: "m"(test_data.regdata[REG_SET_SAVE]), "m"(test_data.regdata[REG_SET_INPUT]), "m"(test_data.regdata[REG_SET_OUTPUT]), "m"(test_data.fn), "m"(test_data.retaddr):); } Any thoughts on that approach? I haven't actually tested it yet. (It would probably nice if I put "memory" in the clobber.) Thanks, Daniel