From patchwork Tue Jul 8 19:45:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 367998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 046141400A3 for ; Wed, 9 Jul 2014 05:45:46 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=pdMvKoEQr0wYA8Ryy w0cB3/TkuFFnY4NtpyWovpVVUMPGcmabwFV5adL6PHyCEtV4zJ17MrLHjPhWSt6Z ZAmaR87EtC1ClBCU8Xg+weljue6h9kbxzGOBK695Ef+gkMDI45iNcXFQm0TzazpI y9cFn/gpY7PSLSw7I2F518bNqo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=3nA0KIjaIsFFeESA3CSL/4i k8pU=; b=Bt/1QHUd125sSWX1RRkrjl9uv4EdUi7qeqvxMSACtiX4AjgG8KlXmDA mXYIsxfLDxIAuTIXSbu9vG5BOzBJ6JHf5bJJb859GFL/P4W4joIiezDH+0u+MEm0 inmSzvtGeRNXYcP0331dXdXUk4oLNkzxis24mIvocjmHtb64mz40= Received: (qmail 14639 invoked by alias); 8 Jul 2014 19:45:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 14623 invoked by uid 89); 8 Jul 2014 19:45:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Jul 2014 19:45:35 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1X4bKT-0004PH-9S from Tom_deVries@mentor.com ; Tue, 08 Jul 2014 12:45:29 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 8 Jul 2014 12:45:29 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Tue, 8 Jul 2014 20:45:27 +0100 Message-ID: <53BC4A53.1020300@mentor.com> Date: Tue, 8 Jul 2014 21:45:23 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Jeff Law CC: Yufeng Zhang , "gcc-patches@gcc.gnu.org" , Marcus Shawcroft , Richard Earnshaw Subject: Re: [PATCH, AArch64, Testsuite] Specify -fno-use-caller-save for func-ret* tests References: <53B2D8F2.9040407@arm.com> <53B2EF40.8090609@redhat.com> In-Reply-To: <53B2EF40.8090609@redhat.com> On 01-07-14 19:26, Jeff Law wrote: > On 07/01/14 09:51, Yufeng Zhang wrote: >> Hi, >> >> This patch resolves a conflict between the aapcs64 test framework for >> func-ret tests and the optimization option -fuse-caller-save, which was >> enabled by default at -O1 or above recently. >> Minor detail: it's enabled by default at -O2 or above: ... { OPT_LEVELS_2_PLUS, OPT_fuse_caller_save, NULL, 1 }, ... >> Basically, the test framework has an inline-assembly based mechanism in >> place which invokes the test facility function right on the return of a >> tested function. >> The compiler with -fuse-caller-save is unable to >> identify the unconventional call graph and carries out the optimization >> regardless. AFAIU, we're overwriting the return register to implement a function call at return in order to see the exact state of registers at return: ... __attribute__ ((noinline)) unsigned char func_return_val_0 (int i, double d, unsigned char t) { asm (""::"r" (i),"r" (d)); asm volatile ("mov %0, x30" : "=r" (saved_return_address)); asm volatile ("mov x30, %0" : : "r" ((unsigned long long) myfunc)); return t; } ... But we're not informing the compiler that a hidden function call takes place. This patch fixes that, and there's no need to disable fuse-caller-save. Tested with aarch64 build. OK for trunk? Thanks, - Tom 2014-07-08 Tom de Vries * gcc.target/aarch64/aapcs64/aapcs64.exp (additional_flags_for_func_ret): Remove. (func-ret-*.c): Use additional_flags. * gcc.target/aarch64/aapcs64/abitest-2.h (FUNC_VAL_CHECK): Add missing call_used_regs clobbers. Index: gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp =================================================================== --- gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp (revision 212294) +++ gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp (working copy) @@ -48,15 +48,11 @@ foreach src [lsort [glob -nocomplain $sr } # Test function return value. -# Disable -fuse-caller-save to prevent the compiler from generating -# conflicting code. -set additional_flags_for_func_ret $additional_flags -append additional_flags_for_func_ret " -fno-use-caller-save" foreach src [lsort [glob -nocomplain $srcdir/$subdir/func-ret-*.c]] { if {[runtest_file_p $runtests $src]} { c-torture-execute [list $src \ $srcdir/$subdir/abitest.S] \ - $additional_flags_for_func_ret + $additional_flags } } Index: gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h =================================================================== --- gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h (revision 212294) +++ gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h (working copy) @@ -80,10 +80,18 @@ __attribute__ ((noinline)) type FUNC_NAM The previous approach of sequentially calling myfunc right after \ this function does not guarantee myfunc see the exact register \ content, as compiler may emit code in between the two calls, \ - especially during the -O0 codegen. */ \ + especially during the -O0 codegen. \ + However, since we're doing a call, we need to clobber all call \ + used regs. */ \ asm volatile ("mov %0, x30" : "=r" (saved_return_address)); \ - asm volatile ("mov x30, %0" : : "r" ((unsigned long long) myfunc)); \ - return t; \ + asm volatile ("mov x30, %0" : : "r" ((unsigned long long) myfunc) : \ + "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", \ + "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", \ + "x16", "x17", "x18", \ + "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", \ + "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", \ + "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31");\ + return t; \ } #include TESTFILE