From patchwork Fri Mar 13 21:54:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 450108 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 C637014007D for ; Sat, 14 Mar 2015 08:55:11 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=K3+Wut3N; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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:content-type; q=dns; s=default; b=sYAugsMObFFr5rHXhjyygeg07FuqC0U1MJtPt8iKZNE caHKT5bFKv5N8cQApsqDmNumRhKVtakolUzydQ5UlcrVo7aMXxjQyTP77AcQ5pGS atw/f1U8RidrV9bVgxXoOQ+VO/z/E5LDIsYvMIFS7dcILFv7p0YxuqTMBPbazvA0 = 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:content-type; s=default; bh=OK3Ti83im9Wh+iZsRqD5wOsI2Is=; b=K3+Wut3Nnt2IpH8Eo EcQ9H3VxVhjChVNBQy/6dCNHW1SZFyzn3Ee69NEDjh8sui3pFOLgsNRjLuPCcpEY CsKkR1PusEhvk8w7P9fgJALXzMfENyNNact0INjR2RlkbNbWAQ/2Vtai4jccQtJK T/E9nTn0k7qzbFH04EOg7/wwag= Received: (qmail 98213 invoked by alias); 13 Mar 2015 21:55:03 -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 98203 invoked by uid 89); 13 Mar 2015 21:55:02 -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, 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; Fri, 13 Mar 2015 21:55:00 +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 t2DLsxb1019752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 13 Mar 2015 17:54:59 -0400 Received: from [10.10.50.234] (unused [10.10.50.234] (may be forged)) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2DLswXJ007546; Fri, 13 Mar 2015 17:54:58 -0400 Message-ID: <55035CB1.4020801@redhat.com> Date: Fri, 13 Mar 2015 15:54:57 -0600 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: Gcc Patch List CC: anton@samba.org Subject: [PATCH] pr 63354 - gcc -pg -mprofile-kernel creates unused stack frames on leaf functions on ppc64le X-IsSubscribed: yes 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. The patch was tested on {powerpc64,powerpc64le}-linux. Martin 2015-03-13 Anton Blanchard PR target/63354 * gcc/config/rs6000/linux64.h (ARGET_KEEP_LEAF_WHEN_PROFILED): Define. * cc/config/rs6000/rs6000.c (rs6000_keep_leaf_when_profiled). New function. 2015-03-13 Martin Sebor PR target/63354 * gcc.target/powerpc/pr63354.c: New test. diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 0879e7e..f51e892 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -59,6 +59,9 @@ extern int dot_symbols; #define TARGET_PROFILE_KERNEL profile_kernel +#undef TARGET_KEEP_LEAF_WHEN_PROFILED +#define TARGET_KEEP_LEAF_WHEN_PROFILED rs6000_keep_leaf_when_profiled + #define TARGET_USES_LINUX64_OPT 1 #ifdef HAVE_LD_LARGE_TOC #undef TARGET_CMODEL diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 3171eef..77731c56 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -24395,6 +24395,15 @@ rs6000_output_function_prologue (FILE *file, rs6000_pic_labelno++; } +/* -mprofile-kernel code calls mcount before the function prolog, + so a profiled leaf function should stay a leaf function. */ + +static bool +rs6000_keep_leaf_when_profiled (void) +{ + return TARGET_PROFILE_KERNEL; +} + /* 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/testsuite/gcc.target/powerpc/pr63354.c b/gcc/testsuite/gcc.target/powerpc/pr63354.c new file mode 100644 index 0000000..dd6ad08 --- /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," } } */