From patchwork Wed May 22 23:39:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 1103754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-501492-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="auG5xKt8"; dkim-atps=neutral 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 458TdY6sC4z9s55 for ; Thu, 23 May 2019 09:40:13 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:date:mime-version:message-id:content-type :content-transfer-encoding; q=dns; s=default; b=jkiUQeaXARI7zlH5 glP6mxoDd8pfIqtcsIulTuvERUlC++CSQBlGL260w+dwh/dVuax+vYZ+O96aQVzN upBvEun1vYBj2uVaZIGI+1n5N6HZRgnOXDYSrTkygr7rDtJLM3Tr+0DJgzILcxtc ZBAcu5YUspi2ibmaMXNM+Q/ZR3w= 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:to:cc :from:subject:date:mime-version:message-id:content-type :content-transfer-encoding; s=default; bh=SJliprYqqUtUuI/S90Pu8S Inj2o=; b=auG5xKt8sKmuWNrizW2UVJtIzgiEqcShNOxGTDMMThfC2aQr6B6f16 h9a6xeaIFV997BGhw61tsEey2NNPwkw7rt1gWWQEO0o/oXkWkyx6iBOOt6Lh0Ubu c9vLASQa9gpkFI3p9tS4/uemlOCV7wcgEElxjEklxVE0a3NUsoszU= Received: (qmail 64870 invoked by alias); 22 May 2019 23:40:06 -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 64862 invoked by uid 89); 22 May 2019 23:40:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=localentry X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 May 2019 23:40:04 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4MNc05K077589 for ; Wed, 22 May 2019 19:39:59 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2sncjn01be-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 May 2019 19:39:59 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 May 2019 00:39:59 +0100 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 23 May 2019 00:39:57 +0100 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4MNdufS37093482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 May 2019 23:39:56 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C2219112061; Wed, 22 May 2019 23:39:56 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 68B96112062; Wed, 22 May 2019 23:39:56 +0000 (GMT) Received: from BigMac.local (unknown [9.85.143.85]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 22 May 2019 23:39:56 +0000 (GMT) To: GCC Patches Cc: Segher Boessenkool From: Bill Schmidt Subject: [PATCH] rs6000: Entry point generation for functions using PC-relative addressing Date: Wed, 22 May 2019 18:39:55 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 x-cbid: 19052223-0052-0000-0000-000003C59F28 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011145; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01207188; UDB=6.00633961; IPR=6.00988163; MB=3.00027009; MTD=3.00000008; XFM=3.00000015; UTC=2019-05-22 23:39:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19052223-0053-0000-0000-00006101B06E Message-Id: <2feecb0e-7ec9-1f3c-dfd4-6b40c4c5f518@linux.ibm.com> Hi, Functions using PC-relative addressing do not use a TOC, so there is no need for a global entry point for TOC setup. Ensure we never generate a global entry point, and use a .localentry directive that sets the upper st_other bits to 1. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Is this okay for trunk? Thanks, Bill [gcc] 2019-05-22 Bill Schmidt * config/rs6000/rs6000.c (rs6000_global_entry_point_needed_p): Return false for PC-relative functions. (rs6000_output_function_prologue): Emit ".localentry name,1" for PC-relative functions. [gcc/testsuite] 2019-05-22 Bill Schmidt * gcc.target/powerpc/localentry-1.c: New file. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 959e222c9cb..23c6d37ab55 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -26191,6 +26191,10 @@ rs6000_global_entry_point_needed_p (void) if (TARGET_SINGLE_PIC_BASE) return false; + /* PC-relative functions never generate a global entry point prologue. */ + if (rs6000_pcrel_p (cfun)) + return false; + /* Ensure we have a global entry point for thunks. ??? We could avoid that if the target routine doesn't need a global entry point, but we do not know whether this is the case at this point. */ @@ -27545,12 +27549,12 @@ rs6000_output_function_prologue (FILE *file) #endif } + const char *name = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); + /* ELFv2 ABI r2 setup code and local entry point. This must follow immediately after the global entry point label. */ if (rs6000_global_entry_point_needed_p ()) { - const char *name = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); - (*targetm.asm_out.internal_label) (file, "LCF", rs6000_pic_labelno); if (TARGET_CMODEL != CMODEL_LARGE) @@ -27601,6 +27605,18 @@ rs6000_output_function_prologue (FILE *file) fputs ("\n", file); } + else if (rs6000_pcrel_p (cfun)) + { + /* All functions compiled to use PC-relative addressing will + have a .localentry value of 0 or 1. For now we set it to + 1 all the time, indicating that the function may clobber + the TOC register r2. Later we may optimize this by setting + it to 0 if the function is a leaf and does not clobber r2. */ + fputs ("\t.localentry\t", file); + assemble_name (file, name); + fputs (",1\n", file); + } + /* Output -mprofile-kernel code. This needs to be done here instead of in output_function_profile since it must go after the ELFv2 ABI local entry point. */ diff --git a/gcc/testsuite/gcc.target/powerpc/localentry-1.c b/gcc/testsuite/gcc.target/powerpc/localentry-1.c new file mode 100644 index 00000000000..15e00d9917e --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/localentry-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-mcpu=future -O2" } */ +/* { dg-require-effective-target powerpc_elfv2 } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=future" } } */ + +/* Ensure we generate ".localentry fn,1" for both leaf and non-leaf + functions. */ + +extern int y (int); + +int x (void) +{ + return y (5); +} + +void z (void) { }; + +/* { dg-final { scan-assembler {\.localentry\t\mx,1\M} } } */ +/* { dg-final { scan-assembler {\.localentry\t\mz,1\M} } } */