From patchwork Wed Apr 11 13:12:45 2018 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: 897176 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-476206-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="i5dPIT3Q"; 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 40Lkx63Rp8z9s35 for ; Wed, 11 Apr 2018 23:12:57 +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:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=sxT10Y6qnk+IJPZDc8v6IxdZDPTMln00UHmAkA9sFqWfr32A0M nPYfG6euMSQ5DwScd5/yQV8679IGSTWlwZ3JFyZLMuf7yQW5XmeCIrj2g2zRN3+c lMOB6bCRsloRWxG25cEhNZ0rAEOOupt2hQukZEFez5d1R0OKNg5/BoBxU= 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:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=u5t+F9Haudh95nFN6AKcW+dJQ3o=; b=i5dPIT3QfEV/VGbXHtKg qvxyTNO+x6xX1o0/sn7LW6+YLVMfvdmiPyvVDAm7nLElIpfr6GdYG0iKhfUY74+L 3SuA7flCnWj2MJXcv5dIRRy/utSdYEZb9k+dr0Z1eq+jdRAqpY0WIAefIr8WCEu4 4lV6Xai6XAFAGFRd3FTe4lk= Received: (qmail 8506 invoked by alias); 11 Apr 2018 13:12:50 -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 8495 invoked by uid 89); 11 Apr 2018 13:12:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Apr 2018 13:12:48 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 09E2FAB4B; Wed, 11 Apr 2018 13:12:46 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Make redirection only for target_clones (PR ipa/85329). To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka Message-ID: <5657d636-a35d-d4f8-d264-ebdbb606a0e4@suse.cz> Date: Wed, 11 Apr 2018 15:12:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi. Following restricts cgraph redirection done in multiple_target.c just to clones that are created in the IPA pass. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Martin gcc/ChangeLog: 2018-04-11 Martin Liska PR ipa/85329 * multiple_target.c (create_dispatcher_calls): Rename to ... (redirect_target_clone_callers): ... this. (expand_target_clones): Record created clones. (ipa_target_clone): Call redirect_target_clone_callers only for these clones. --- gcc/multiple_target.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c index b006a5ab6ec..5bd88fbd83c 100644 --- a/gcc/multiple_target.c +++ b/gcc/multiple_target.c @@ -58,11 +58,11 @@ replace_function_decl (tree *op, int *walk_subtrees, void *data) return NULL; } -/* If the call in NODE has multiple target attribute with multiple fields, - replace it with dispatcher call and create dispatcher (once). */ +/* If the call in NODE is a target_clone attribute clone, redirect all + edges and references that point to cgraph NODE. */ static void -create_dispatcher_calls (struct cgraph_node *node) +redirect_target_clone_callers (struct cgraph_node *node) { ipa_ref *ref; @@ -300,10 +300,12 @@ create_target_clone (cgraph_node *node, bool definition, char *name) } /* If the function in NODE has multiple target attributes - create the appropriate clone for each valid target attribute. */ + create the appropriate clone for each valid target attribute. + TO_REDIRECT is a vector where we place all newly created clones. */ static bool -expand_target_clones (struct cgraph_node *node, bool definition) +expand_target_clones (struct cgraph_node *node, bool definition, + auto_vec &to_redirect) { int i; /* Parsing target attributes separated by comma. */ @@ -404,6 +406,8 @@ expand_target_clones (struct cgraph_node *node, bool definition) before->next = after; after->prev = before; DECL_FUNCTION_VERSIONED (new_node->decl) = 1; + + to_redirect.safe_push (new_node); } XDELETEVEC (attrs); @@ -420,6 +424,8 @@ expand_target_clones (struct cgraph_node *node, bool definition) = targetm.target_option.valid_attribute_p (node->decl, NULL, TREE_VALUE (attributes), 0); input_location = saved_loc; + to_redirect.safe_push (node); + return ret; } @@ -428,13 +434,12 @@ ipa_target_clone (void) { struct cgraph_node *node; - bool target_clone_pass = false; + auto_vec nodes_to_redirect; FOR_EACH_FUNCTION (node) - target_clone_pass |= expand_target_clones (node, node->definition); + expand_target_clones (node, node->definition, nodes_to_redirect); - if (target_clone_pass) - FOR_EACH_FUNCTION (node) - create_dispatcher_calls (node); + for (unsigned i = 0; i < nodes_to_redirect.length (); i++) + redirect_target_clone_callers (nodes_to_redirect[i]); return 0; }