From patchwork Thu Jan 21 16:48:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 571254 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 86AC114030F for ; Fri, 22 Jan 2016 03:50:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CKMpoDOi; 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:subject:from:to:cc:date:content-type:mime-version :content-transfer-encoding; q=dns; s=default; b=dqH9KBGtXnUSQiB0 la3vzwRI8wuttryzQ5+3w+9Ur+9uMJOiL12dhc3jsoW9xS4DijAzCfQYu7PQkDOO 7+AqOUsv1qV6DChSRuaDn85x2O3rhl88vxUvaFMYk2ctW80sdpl51n9zLjzeU+uQ 4+KAdtONtvZT12W2oTVLCm+ogj4= 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:subject:from:to:cc:date:content-type:mime-version :content-transfer-encoding; s=default; bh=uT1LbUKwvX122/8Rzwj6Xu fHVdQ=; b=CKMpoDOiI6NvBKwckf7deAk1PbdV+P7tgGaAVuUE96fj3yLTK5vTGF /zlz4lsC/RQggswEQv2eD683/u9ictJ2ftj54rOSUR2lPwp1VByeuhpNvNE2CFDU 8Bnoe6W0ZbBqm+XU/rkzTEPpMwcTPhW3vF61nwu0gRZ1fiWB0GPEw= Received: (qmail 24634 invoked by alias); 21 Jan 2016 16:50:29 -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 24503 invoked by uid 89); 21 Jan 2016 16:50:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Hx-languages-length:2700, his X-HELO: e32.co.us.ibm.com Received: from e32.co.us.ibm.com (HELO e32.co.us.ibm.com) (32.97.110.150) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 21 Jan 2016 16:50:26 +0000 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 21 Jan 2016 09:48:58 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 21 Jan 2016 09:48:51 -0700 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: wschmidt@linux.vnet.ibm.com X-IBM-RcptTo: gcc-patches@gcc.gnu.org Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id CDE1819D804C for ; Thu, 21 Jan 2016 09:36:48 -0700 (MST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0LGmlwS36765834 for ; Thu, 21 Jan 2016 16:48:47 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0LGmkYq015461 for ; Thu, 21 Jan 2016 11:48:46 -0500 Received: from [9.80.43.206] ([9.80.43.206]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u0LGmdDr014475; Thu, 21 Jan 2016 11:48:40 -0500 Message-ID: <1453394918.22933.3.camel@gnopaine> Subject: [PATCH, rs6000] Fix PR63354 From: Bill Schmidt To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, anton@samba.org Date: Thu, 21 Jan 2016 10:48:38 -0600 Mime-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16012116-0005-0000-0000-00001BA71E26 X-IsSubscribed: yes Hi, Anton Blanchard proposed a fix to his own bug report in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63354, but never submitted the patch upstream. I've added a formal test case and am submitting on his behalf. The patch simply ensures that we don't stack a frame for leaf procedures when called with -pg -mprofile-kernel. The automatically generated calls to _mcount occur prior to the prolog and do not require us to stack a frame. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Is this ok for trunk? Thanks, Bill [gcc] 2016-01-21 Anton Blanchard Bill Schmidt PR target/63354 * config/rs6000/linux64.h (TARGET_KEEP_LEAF_WHEN_PROFILED): New #define. * config/rs6000/rs6000.c (rs6000_keep_leaf_when_profiled): New function. [gcc/testsuite] 2016-01-21 Anton Blanchard Bill Schmidt PR target/63354 * gcc.target/powerpc/pr63354.c: New test. Index: gcc/config/rs6000/linux64.h =================================================================== --- gcc/config/rs6000/linux64.h (revision 232677) +++ gcc/config/rs6000/linux64.h (working copy) @@ -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 Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 232677) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -26237,6 +26237,14 @@ 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 () +{ + 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 Index: gcc/testsuite/gcc.target/powerpc/pr63354.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr63354.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/pr63354.c (working copy) @@ -0,0 +1,11 @@ +/* Verify that we don't stack a frame for leaf functions when using + -pg -mprofile-kernel. */ + +/* { dg-do compile { target { powerpc64*-*-* } } } */ +/* { dg-options "-O2 -pg -mprofile-kernel" } */ +/* { dg-final { scan-assembler-not "mtlr" } } */ + +int foo(void) +{ + return 1; +}