From patchwork Fri Sep 15 08:10:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 814134 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-462201-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="gpcMDDcs"; 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 3xtp4b2Q5Qz9sPr for ; Fri, 15 Sep 2017 18:10:54 +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:message-id:date:mime-version:content-type; q=dns; s=default; b=Sn5ScqqmrK9ZU3l33IJZa+wMXQRBDJ9xinJr9F/33iLkFKd3bR 80WvlWYNSA29qFyYUJ1ujgOez/NpLiO3VbAJq2sBdeuHJOc/m9M3G0mrLgCdUo2D AN3aU1Xa0cA0z6mgEsXp4qOcRasXKkm8JyZ6h/Rb3wl951Lig+Nz5/0II= 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:message-id:date:mime-version:content-type; s= default; bh=KVGuAulitFqYNBk1OK/d8D2OlIc=; b=gpcMDDcsoAyYbaO8BqRi j7/yGQ8s6xowCdP47T2GlkQ8fai2OSpLIWQoAebX8NakdZTzLlXofh7dmPJH16VJ Sz1I1XUA5zZPD/GRaLS/N4muhJKHZ3SNoedNq+D4H6hjCge61NyXScyUNOB/iVG0 vGrWFa4hIimzz00l0eags3U= Received: (qmail 49064 invoked by alias); 15 Sep 2017 08:10:36 -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 48976 invoked by uid 89); 15 Sep 2017 08:10:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, SPF_PASS autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 08:10:27 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 34B6DABB3; Fri, 15 Sep 2017 08:10:24 +0000 (UTC) To: GCC Patches Cc: "wschmidt@gcc.gnu.org" From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: Backports for GCC 7 branch Message-ID: <1147b9d2-91eb-508e-d70b-f8307aa1bc93@suse.cz> Date: Fri, 15 Sep 2017 10:10:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hello. I'm going to install following backports. Last patch fixes wrongly backported patch in gcc/gimple-ssa-strength-reduction.c. Patches can bootstrap on ppc64le-redhat-linux and survives regression tests. Martin From f075fe82a3e4244de9fe9728180dd4325c6e466e Mon Sep 17 00:00:00 2001 From: marxin Date: Wed, 28 Jun 2017 12:47:24 +0000 Subject: [PATCH 1/8] Backport r249735 gcc/ChangeLog: 2017-06-28 Martin Liska PR ipa/81128 * ipa-visibility.c (non_local_p): Handle visibility. gcc/c-family/ChangeLog: 2017-06-28 Martin Liska PR ipa/81128 * c-attribs.c (handle_alias_ifunc_attribute): Append ifunc alias to a function declaration. gcc/testsuite/ChangeLog: 2017-06-28 Martin Liska PR ipa/81128 * gcc.target/i386/pr81128.c: New test. --- gcc/c-family/c-attribs.c | 11 ++++-- gcc/ipa-visibility.c | 3 +- gcc/testsuite/gcc.target/i386/pr81128.c | 65 +++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr81128.c diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index f2a88e147ba..90b17bc00d2 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -1764,9 +1764,14 @@ handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args, TREE_STATIC (decl) = 1; if (!is_alias) - /* ifuncs are also aliases, so set that attribute too. */ - DECL_ATTRIBUTES (decl) - = tree_cons (get_identifier ("alias"), args, DECL_ATTRIBUTES (decl)); + { + /* ifuncs are also aliases, so set that attribute too. */ + DECL_ATTRIBUTES (decl) + = tree_cons (get_identifier ("alias"), args, + DECL_ATTRIBUTES (decl)); + DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("ifunc"), + NULL, DECL_ATTRIBUTES (decl)); + } } else { diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index d5a3ae56c46..da4a22e7329 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -97,7 +97,8 @@ non_local_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) && !DECL_EXTERNAL (node->decl) && !node->externally_visible && !node->used_from_other_partition - && !node->in_other_partition); + && !node->in_other_partition + && node->get_availability () >= AVAIL_AVAILABLE); } /* Return true when function can be marked local. */ diff --git a/gcc/testsuite/gcc.target/i386/pr81128.c b/gcc/testsuite/gcc.target/i386/pr81128.c new file mode 100644 index 00000000000..90a567ad690 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81128.c @@ -0,0 +1,65 @@ +/* PR ipa/81128 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-require-ifunc "" } */ + + +#include +#include +#include + +int resolver_fn = 0; +int resolved_fn = 0; + +static inline void +do_it_right_at_runtime_A () +{ + resolved_fn++; +} + +static inline void +do_it_right_at_runtime_B () +{ + resolved_fn++; +} + +static inline void do_it_right_at_runtime (void); + +void do_it_right_at_runtime (void) + __attribute__ ((ifunc ("resolve_do_it_right_at_runtime"))); + +static void (*resolve_do_it_right_at_runtime (void)) (void) +{ + srand (time (NULL)); + int r = rand (); + resolver_fn++; + + /* Use intermediate variable to get a warning for non-matching + * prototype. */ + typeof(do_it_right_at_runtime) *func; + if (r & 1) + func = do_it_right_at_runtime_A; + else + func = do_it_right_at_runtime_B; + + return (void *) func; +} + +int +main (void) +{ + const unsigned int ITERS = 10; + + for (int i = ITERS; i > 0; i--) + { + do_it_right_at_runtime (); + } + + if (resolver_fn != 1) + __builtin_abort (); + + if (resolved_fn != 10) + __builtin_abort (); + + return 0; +} -- 2.14.1