From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93512 invoked by alias); 24 Mar 2015 20:18:26 -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 93499 invoked by uid 89); 24 Mar 2015 20:18:25 -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,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 24 Mar 2015 20:18:15 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2OKIAX3024790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Mar 2015 16:18:10 -0400 Received: from [10.10.51.170] (unused [10.10.51.170] (may be forged)) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2OKI8wj015526; Tue, 24 Mar 2015 16:18:08 -0400 Message-ID: <5511C67F.5040602@redhat.com> Date: Tue, 24 Mar 2015 20:18:00 -0000 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Iain Sandoe CC: Segher Boessenkool , Gcc Patch List , anton@samba.org Subject: Re: [PATCH] pr 63354 - gcc -pg -mprofile-kernel creates unused stack frames on leaf functions on ppc64le References: <55035CB1.4020801@redhat.com> <20150314143434.GC3690@gate.crashing.org> <5506184F.8090006@redhat.com> <210B149C-A8AB-4A0C-98AA-90D72741A7AF@codesourcery.com> <5510D0F3.4060606@redhat.com> <1209B144-07A2-40DE-974E-47DA5A8B7DE9@codesourcery.com> In-Reply-To: <1209B144-07A2-40DE-974E-47DA5A8B7DE9@codesourcery.com> Content-Type: multipart/mixed; boundary="------------060302070802010302010200" X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg01267.txt.bz2 This is a multi-part message in MIME format. --------------060302070802010302010200 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-length: 1038 > I'm assuming that you mean a cross-compile (which is a stage1 without -werror). If you look in the build output (I just repeated this on x86_64-darwin12 X powerpc-darwin9) you'll see: > > /GCC/gcc-trunk/gcc/config/rs6000/rs6000.c:24404:1: warning: ‘bool rs6000_keep_leaf_when_profiled()’ defined but not used [-Wunused-function] > rs6000_keep_leaf_when_profiled (void) > ^ > > this becomes a bootstrap error at stage#2. If you don't see that, then I have don't have the same patch applied as you :). Yes, I meant a cross-compile. I don't have a Darwin environment but I managed to reproduce it while building stage1 with -Werror (after fixing a number of problems that cause the build to fail earlier on). Thanks for your patience. Attached is an updated patch with your suggested change (i.e., defining the TARGET_KEEP_LEAF_WHEN_PROFILED macro in rs6000.h instead of linux64.h). I tested the patch by building stage1 with -Werror for both powerpc64-darwin9 and powerpc64-unknown-linux-gnu (both on the latter target). Martin --------------060302070802010302010200 Content-Type: text/x-patch; name="gcc-63354.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gcc-63354.patch" Content-length: 2186 2015-03-24 Anton Blanchard PR target/63354 * config/rs6000/rs6000.h (TARGET_KEEP_LEAF_WHEN_PROFILED): Define. * config/rs6000/rs6000.c (rs6000_keep_leaf_when_profiled): New function. 2015-03-24 Martin Sebor PR target/63354 * gcc.target/powerpc/pr63354.c: New test. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 31b46ea..f1508b9 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -24397,6 +24397,23 @@ rs6000_output_function_prologue (FILE *file, rs6000_pic_labelno++; } +/* -mprofile-kernel code calls mcount before the function prologue, + so a profiled leaf function should stay a leaf function. */ + +static bool +rs6000_keep_leaf_when_profiled (void) +{ + switch (DEFAULT_ABI) + { + case ABI_AIX: + case ABI_ELFv2: + return TARGET_PROFILE_KERNEL; + + default: + return true; + } +} + /* Non-zero if vmx regs are restored before the frame pop, zero if we restore after the pop when possible. */ #define ALWAYS_RESTORE_ALTIVEC_BEFORE_POP 0 diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index ef6bb2f..50394b0 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -703,6 +703,9 @@ extern unsigned char rs6000_recip_bits[]; #define TARGET_CPU_CPP_BUILTINS() \ rs6000_cpu_cpp_builtins (pfile) +#undef TARGET_KEEP_LEAF_WHEN_PROFILED +#define TARGET_KEEP_LEAF_WHEN_PROFILED rs6000_keep_leaf_when_profiled + /* This is used by rs6000_cpu_cpp_builtins to indicate the byte order we're compiling for. Some configurations may need to override it. */ #define RS6000_CPU_CPP_ENDIAN_BUILTINS() \ diff --git a/gcc/testsuite/gcc.target/powerpc/pr63354.c b/gcc/testsuite/gcc.target/powerpc/pr63354.c new file mode 100644 index 0000000..9e635cc --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr63354.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target { powerpc64*-*-linux* } } } */ +/* { dg-options "-O2 -pg -mprofile-kernel" } */ + +int foo (void) +{ + return 1; +} + +/* { dg-final { scan-assembler "bl _mcount" } } */ +/* { dg-final { scan-assembler-not "(addi|stdu) 1," } } */ --------------060302070802010302010200--