From patchwork Tue Oct 8 15:20:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 1173387 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-510475-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="mrjzqxHW"; 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 46ngz62Ws6z9s7T for ; Wed, 9 Oct 2019 02:20:49 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:in-reply-to:message-id:date:mime-version :content-type; q=dns; s=default; b=vDkfkxt6K9GoxoAY7B9n3cHsDa/mG VCOc61KLkTjaIE8grfEYoPQNCCZMZ8XCbSq6shSY2sOzaRHaeh0Ee2xWAY/OnwOY 0okNO/+GGPIIZLMGsrsagzyVPnytEvjtxL/LsDC8Iy8LUyWuUZl0uXUG157H6WDz sTSwxXuLUNAYoY= 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 :from:subject:in-reply-to:message-id:date:mime-version :content-type; s=default; bh=HOAtTOBOuAAfI+cOIPU59V0HNJs=; b=mrj zqxHWY8mSM7U8wht+Alj6tMMaUCyusdrXDdMX8iTUSsrg0tPiqmK1YxVopTJyUoV y/Jnj463gXl1psz9/ryrhVboBA9JdxDHBuHwyHzXuJ9Xs/Eesukg5WXf9bXQkejO inYsBnxApA5RHQ80aaqUdN5lwlPxRh3rh6yirhPQ= Received: (qmail 99271 invoked by alias); 8 Oct 2019 15:20:40 -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 99205 invoked by uid 89); 8 Oct 2019 15:20:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Oct 2019 15:20:37 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3BA0D1570 for ; Tue, 8 Oct 2019 08:20:36 -0700 (PDT) Received: from [10.2.206.37] (e107157-lin.cambridge.arm.com [10.2.206.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 016A03F68E for ; Tue, 8 Oct 2019 08:20:35 -0700 (PDT) To: gcc-patches From: "Andre Vieira (lists)" Subject: [Patch 1/2][ipa] Add target hook to sanitize cloned declaration's attributes In-Reply-To: Message-ID: <78b498f6-b5bd-1a59-5ec7-1883e31ea633@arm.com> Date: Tue, 8 Oct 2019 16:20:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, This patch adds a new target hook called TARGET_HOOK_SANITIZE_CLONE_ATTRIBUTES. This hook is meant to give each target the ability to sanitize a cloned's declaration attribute list. Is this OK for trunk? Cheers, Andre gcc/ChangeLog: 2019-10-08 Andre Vieira * ipa-cp.c(create_specialized_node): Call new target hook when creating a new node. * target.def(sanitize_clone_attributes): New target hook. * targhooks.c(default_sanitize_clone_attributes): New. * targhooks.h(default_sanitize_clone_attributes): New. * doc/tm.texi.in: Document new target hook. * doc/tm.texi: Regenerated diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index a86c210d4fe390bd0356b6e50ba7c6c34a36239a..5c1149ccf47576d8d803d1ab712f6f1b9342d74c 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -12039,6 +12039,11 @@ If defined, this function returns an appropriate alignment in bits for an atomic ISO C11 requires atomic compound assignments that may raise floating-point exceptions to raise exceptions corresponding to the arithmetic operation whose result was successfully stored in a compare-and-exchange sequence. This requires code equivalent to calls to @code{feholdexcept}, @code{feclearexcept} and @code{feupdateenv} to be generated at appropriate points in the compare-and-exchange sequence. This hook should set @code{*@var{hold}} to an expression equivalent to the call to @code{feholdexcept}, @code{*@var{clear}} to an expression equivalent to the call to @code{feclearexcept} and @code{*@var{update}} to an expression equivalent to the call to @code{feupdateenv}. The three expressions are @code{NULL_TREE} on entry to the hook and may be left as @code{NULL_TREE} if no code is required in a particular place. The default implementation leaves all three expressions as @code{NULL_TREE}. The @code{__atomic_feraiseexcept} function from @code{libatomic} may be of use as part of the code generated in @code{*@var{update}}. @end deftypefn +@deftypefn {Target Hook} void TARGET_SANITIZE_CLONE_ATTRIBUTES (struct cgraph_node *@var{}) +This target hook sanitizes the cloned @code{*@var{node}} declaration +attributes. +@end deftypefn + @deftypefn {Target Hook} void TARGET_RECORD_OFFLOAD_SYMBOL (tree) Used when offloaded functions are seen in the compilation unit and no named sections are available. It is called once for each symbol that must be diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 06dfcda35abea7396c288a59c38ee4ef57c6fef6..f4ef164a595ca1c2e286a7d26020b63b4c966728 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -8134,6 +8134,8 @@ and the associated definitions of those functions. @hook TARGET_ATOMIC_ASSIGN_EXPAND_FENV +@hook TARGET_SANITIZE_CLONE_ATTRIBUTES + @hook TARGET_RECORD_OFFLOAD_SYMBOL @hook TARGET_OFFLOAD_OPTIONS diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index b4fb74e097e2c9f80aa38f8e150be593200d9bdf..9c2154fa78d59873243fc7d7717fb9cab83101ac 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -124,6 +124,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-ccp.h" #include "stringpool.h" #include "attribs.h" +#include "target.h" template class ipcp_value; @@ -4017,6 +4018,9 @@ create_specialized_node (struct cgraph_node *node, ipcp_discover_new_direct_edges (new_node, known_csts, known_contexts, aggvals); callers.release (); + + targetm.sanitize_clone_attributes (new_node); + return new_node; } diff --git a/gcc/target.def b/gcc/target.def index f9446fa05a22c79154c2ef36d3d8aea48a5efcc6..18301565e5131fa8b2f194bc73aa0c55d30cb9ef 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -6582,6 +6582,13 @@ DEFHOOK void, (tree *hold, tree *clear, tree *update), default_atomic_assign_expand_fenv) +DEFHOOK +(sanitize_clone_attributes, +"This target hook sanitizes the cloned @code{*@var{node}} declaration\n\ +attributes.", +void, (struct cgraph_node *), +default_sanitize_clone_attributes) + /* Leave the boolean fields at the end. */ /* True if we can create zeroed data by switching to a BSS section diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 5aba67660f85406b9fd475e75a3cc65b0d1952f5..0191d0ed36eb60fc79bf718b9782ef6c99c77fc4 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -284,4 +284,6 @@ extern rtx default_speculation_safe_value (machine_mode, rtx, rtx, rtx); extern void default_remove_extra_call_preserved_regs (rtx_insn *, HARD_REG_SET *); +extern void default_sanitize_clone_attributes (struct cgraph_node *); + #endif /* GCC_TARGHOOKS_H */ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index ed77afb1da57e59bc0725dc0d6fac477391bae03..35d2114956bd27f250335d918d0b3d81d962472b 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -2120,6 +2120,12 @@ default_atomic_assign_expand_fenv (tree *, tree *, tree *) { } +/* Default implementation of TARGET_SANITIZE_CLONE_ATTRIBUTES. */ + +void default_sanitize_clone_attributes (struct cgraph_node *node) +{ +} + #ifndef PAD_VARARGS_DOWN #define PAD_VARARGS_DOWN BYTES_BIG_ENDIAN #endif From patchwork Tue Oct 8 15:20:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 1173388 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-510476-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="puAMxPQs"; 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 46ngzL3LVSz9sP7 for ; Wed, 9 Oct 2019 02:21:02 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :in-reply-to:to:from:subject:message-id:date:mime-version :content-type; q=dns; s=default; b=OofZXNXiJY4wxbsVFLWAYQ4diMYco YFE7eekewNDxpoyG/N/UTgaw0zw+WY+kwgY9gUhdEVzGV3/avySFwaS7tkVK40vZ ANVi7AOGBIvzv32nMfWWZHeDTx0bP/52OgPvwm2m+XHZ0Z0Mdgu+LO6o3NakE/o3 1l1Y3pL+wzvqrs= 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 :in-reply-to:to:from:subject:message-id:date:mime-version :content-type; s=default; bh=RGbLmH7a580Yq9Tvxn/LcldKCyY=; b=puA MxPQsbybZlJhW8qFz+rFHuGrGUKeNnCgZpmWLUGj3V5d8pAD1ox6379dKYCyWKVl NmjTny6p6yYvoNGTcFY5D8Lky6BOaG0HKQEZMfV9NvK6KPzS+Xf93Vn8P/fmkkI7 hPay5CE20WhTgrVggVRsIEOOkXjSwvdhT8kD/d7I= Received: (qmail 100240 invoked by alias); 8 Oct 2019 15:20:48 -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 100117 invoked by uid 89); 8 Oct 2019 15:20:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Oct 2019 15:20:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 17B7E1570 for ; Tue, 8 Oct 2019 08:20:44 -0700 (PDT) Received: from [10.2.206.37] (e107157-lin.cambridge.arm.com [10.2.206.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D2C093F68E for ; Tue, 8 Oct 2019 08:20:43 -0700 (PDT) In-Reply-To: To: gcc-patches From: "Andre Vieira (lists)" Subject: [Patch 2/2][Arm] Implement TARGET_HOOK_SANITIZE_CLONE_ATTRIBUTES to remove cmse_nonsecure_entry Message-ID: <5a9d0431-f483-01bb-01d0-949e9badb765@arm.com> Date: Tue, 8 Oct 2019 16:20:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, This patch implements the TARGET_HOOK_SANITIZE_CLONE_ATTRIBUTES for the arm backend to remove the 'cmse_nonsecure_entry' attribute from cmse. Bootstrapped the series on x86_64 and built arm-none-eabi, running the cmse testsuite for armv8-m.main and armv8-m.base. Is this OK for trunk? Cheers, Andre gcc/ChangeLog: 2019-10-08 Andre Vieira * config/arm/arm.c (TARGET_SANITIZE_CLONE_ATTRIBUTES): Define. (arm_sanitize_clone_attributes): New. gcc/testsuite/ChangeLog: 2019-10-08 Andre Vieira * gcc.target/arm/cmse/ipa-clone.c: New test. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 9f0975dc0710626ef46abecaa3a205e993821118..173172bd28303469faded6b7a84a0b353b62de18 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -811,6 +811,9 @@ static const struct attribute_spec arm_attribute_table[] = #undef TARGET_CONSTANT_ALIGNMENT #define TARGET_CONSTANT_ALIGNMENT arm_constant_alignment + +#undef TARGET_SANITIZE_CLONE_ATTRIBUTES +#define TARGET_SANITIZE_CLONE_ATTRIBUTES arm_sanitize_clone_attributes /* Obstack for minipool constant handling. */ static struct obstack minipool_obstack; @@ -31999,6 +32002,15 @@ arm_constant_alignment (const_tree exp, HOST_WIDE_INT align) return align; } +static void +arm_sanitize_clone_attributes (struct cgraph_node * node) +{ + tree attrs = DECL_ATTRIBUTES (node->decl); + if (lookup_attribute ("cmse_nonsecure_entry", attrs)) + attrs = remove_attribute ("cmse_nonsecure_entry", attrs); + DECL_ATTRIBUTES (node->decl) = attrs; +} + /* Emit a speculation barrier on target architectures that do not have DSB/ISB directly. Such systems probably don't need a barrier themselves, but if the code is ever run on a later architecture, it diff --git a/gcc/testsuite/gcc.target/arm/cmse/ipa-clone.c b/gcc/testsuite/gcc.target/arm/cmse/ipa-clone.c new file mode 100644 index 0000000000000000000000000000000000000000..6ab4c34f7499f9615b5d44c633bb5f9d69e88d39 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/ipa-clone.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-mcmse" } */ +/* { dg-additional-options "-Ofast" } */ + +#include + +int __attribute__ ((cmse_nonsecure_entry)) +foo (int a) +{ + return 1; +} + +int __attribute__ ((cmse_nonsecure_entry)) +bar (int a) +{ + return 1; +} + +int main (void) +{ + return 0; +} + +/* { dg-final { scan-assembler "foo.constprop.0:" } } */ +/* { dg-final { scan-assembler-not "__acle_se_foo.constprop.0:" } } */ +/* { dg-final { scan-assembler "foo:" } } */ +/* { dg-final { scan-assembler "__acle_se_foo:" } } */ +