From patchwork Wed Mar 1 06:37:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 734089 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 3vY5NS27Qvz9s81 for ; Wed, 1 Mar 2017 17:37:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Rj9siLWi"; 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:date :from:to:subject:mime-version:content-type:message-id; q=dns; s= default; b=FOlQuV/fZqcqye8oQyZDxGc4ZpuobElY6ulnc85oXaSdCe95UOUoz b448HXF75ewEpSV5QGSBW3luc1uZ336RaLRMLisPFeBFJn/whMH9XnS3h/y1HxMZ JA+nM4LVdz/HUGdz5y53i9HDHAp13gPBtNyH8r8xjCNIX4behpBbio= 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:date :from:to:subject:mime-version:content-type:message-id; s= default; bh=4vU94rGeXiT/+bTtfP1vEFmWtOI=; b=Rj9siLWib5ntfY2xUdr1 h/CTF7YkiyBHzSO7in1SjiIvLCU8paL/MC2zNHEVzNW94UsMyV6Syh7wcKowylM7 QCmVlaghIFfldJ1YxkmgieYPMQpNqrcc47wMpBZ4dSTv1Cg2Jz5PCdJUMj1kT3oS knb8t/E8XKM3UHAAkYWwJgc= Received: (qmail 16537 invoked by alias); 1 Mar 2017 06:37:25 -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 16525 invoked by uid 89); 1 Mar 2017 06:37:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=HTo:U*wschmidt, King, king, Hx-languages-length:2880 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Mar 2017 06:37:23 +0000 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v216VqAn111971 for ; Wed, 1 Mar 2017 01:37:20 -0500 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 28ws1y8fua-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 01 Mar 2017 01:37:20 -0500 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 28 Feb 2017 23:37:19 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 28 Feb 2017 23:37:16 -0700 Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 6436F19D801C; Tue, 28 Feb 2017 23:36:27 -0700 (MST) Received: from b01ledav03.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v216bFTu38338628; Wed, 1 Mar 2017 06:37:15 GMT Received: from b01ledav03.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D55A9B2054; Wed, 1 Mar 2017 01:37:13 -0500 (EST) Received: from ibm-tiger.the-meissners.org (unknown [9.32.77.111]) by b01ledav03.gho.pok.ibm.com (Postfix) with ESMTP id BA6BDB2050; Wed, 1 Mar 2017 01:37:13 -0500 (EST) Received: by ibm-tiger.the-meissners.org (Postfix, from userid 500) id D539547A47; Wed, 1 Mar 2017 01:37:14 -0500 (EST) Date: Wed, 1 Mar 2017 01:37:14 -0500 From: Michael Meissner To: gcc-patches@gcc.gnu.org, Segher Boessenkool , David Edelsohn , Bill Schmidt Subject: [PATCH], PR target/79434, fix PowerPC recursive calls that can replaced at runtime Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , David Edelsohn , Bill Schmidt MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17030106-0024-0000-0000-00001606299A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006701; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000205; SDB=6.00828433; UDB=6.00406031; IPR=6.00605950; BA=6.00005176; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014481; XFM=3.00000011; UTC=2017-03-01 06:37:18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030106-0025-0000-0000-00004924C22E Message-Id: <20170301063714.GA14043@ibm-tiger.the-meissners.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-01_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1703010064 X-IsSubscribed: yes This patch fixes PR target/79439, which is a recursive call when the 64-bit code is compiled with -fpic doesn't have the NOP after the call. It is possible for the function to be overriden at link time. In such a case, the call should call the module that is overriding the call, rather than itself. The following patch was tested on a little endian Power8 Linux system (64-bit only), a big endian Power8 Linux system (both 32-bit and 64-bit), and a big endian Power7 Linux system (both 32-bit and 64-bit). There were no regressions in the test suite, and I verified that the new test ran successfully in 64-bit mode. Can I check this patch into the trunk? Since the bug was reported against GCC 6, can I apply the patch to GCC 6 assuming the patch applies cleanly and has no regressions after a burn in period on the GCC 7 trunk? [gcc] 2017-02-28 Michael Meissner PR target/79439 * config/rs6000/predicates.md (current_file_function_operand): Do not allow self calls to be local if the function is replaceable. [gcc/testsuite] 2017-02-28 Michael Meissner PR target/79439 * gcc.target/powerpc/pr79439.c: New test. Index: gcc/config/rs6000/predicates.md =================================================================== --- gcc/config/rs6000/predicates.md (revision 245787) +++ gcc/config/rs6000/predicates.md (working copy) @@ -1110,7 +1110,8 @@ (define_predicate "current_file_function (and (match_code "symbol_ref") (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op)) && (SYMBOL_REF_LOCAL_P (op) - || op == XEXP (DECL_RTL (current_function_decl), 0)) + || (op == XEXP (DECL_RTL (current_function_decl), 0) + && !decl_replaceable_p (current_function_decl))) && !((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && (SYMBOL_REF_EXTERNAL_P (op) Index: gcc/testsuite/gcc.target/powerpc/pr79439.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr79439.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/pr79439.c (revision 0) @@ -0,0 +1,26 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-options "-O2 -fpic" } */ + +/* Bug 79439 -- we should not eliminate NOP in 'rec' call because it can be + interposed at link time for 64-bit ABIs. We need -fpic to tell the compiler + functions may be interposed. */ + +int f (void); + +void +g (void) +{ +} + +int +rec (int a) +{ + int ret = 0; + if (a > 10 && f ()) + ret += rec (a - 1); + g (); + return a + ret; +} + +/* { dg-final { scan-assembler-times {\mnop\M} 3 } } */