From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70940 invoked by alias); 14 Mar 2015 14:34:40 -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 70922 invoked by uid 89); 14 Mar 2015 14:34:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: gate.crashing.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 14 Mar 2015 14:34:38 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id t2EEYY0X026241; Sat, 14 Mar 2015 09:34:35 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id t2EEYY7c026239; Sat, 14 Mar 2015 09:34:34 -0500 Date: Sat, 14 Mar 2015 14:34:00 -0000 From: Segher Boessenkool To: Martin Sebor Cc: Gcc Patch List , anton@samba.org Subject: Re: [PATCH] pr 63354 - gcc -pg -mprofile-kernel creates unused stack frames on leaf functions on ppc64le Message-ID: <20150314143434.GC3690@gate.crashing.org> References: <55035CB1.4020801@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55035CB1.4020801@redhat.com> User-Agent: Mutt/1.4.2.3i X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00780.txt.bz2 On Fri, Mar 13, 2015 at 03:54:57PM -0600, Martin Sebor wrote: > Attached is a patch that eliminates the unused stack frame > allocated by gcc 5 with -pg -mprofile-kernel on powepc64le > and brings the code into parity with previous gcc versions. > > The patch doesn't do anything to change the emitted code > when -mprofile-kernel is used without -pg. Since the former > option isn't fully documented (as noted in pr 65372) it's > unclear what effect it should be expected to have without > -pg. -mprofile-kernel does nothing without profiling enabled. Maybe it should just have been called -pk or something horrid like that. The effect it should have is to do what the only user of the option (the 64-bit PowerPC Linux kernel) wants. The effect it does have is to make the 64-bit ABI more like the 32-bit ABI for mcount. > 2015-03-13 Anton Blanchard > > PR target/63354 > * gcc/config/rs6000/linux64.h (ARGET_KEEP_LEAF_WHEN_PROFILED): Define. ^ typo > * cc/config/rs6000/rs6000.c (rs6000_keep_leaf_when_profiled). New ^ typo ^ typo It shouldn't have "gcc/" in the path names at all, actually. > +/* -mprofile-kernel code calls mcount before the function prolog, "prologue". > + so a profiled leaf function should stay a leaf function. */ > + > +static bool > +rs6000_keep_leaf_when_profiled (void) > +{ > + return TARGET_PROFILE_KERNEL; > +} Something like switch (DEFAULT_ABI) { case ABI_AIX: case ABI_ELFv2: return TARGET_PROFILE_KERNEL; default: return true; } although I'm not sure about Darwin here. More conservative is to return false for anything untested, of course. > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr63354.c > @@ -0,0 +1,10 @@ > +/* { dg-do compile { target { powerpc*-*-* } } } */ > +/* { 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," } } */ Either you should run this only on AIX/ELFv2 ABIs, or you want to test for "stwu" as well. Bare "1" does not work for all assemblers (only Darwin again?) Segher