From patchwork Mon Nov 24 16:18:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 414036 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 3540A140187 for ; Tue, 25 Nov 2014 03:18:23 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=Ae6hffXjTy/p424mKo4lzopiuevWduaNUSW0PBLmJJZmp/h8mRr4M XkrenBwoorZG2kaycFGoQm/X2UU1nTNl+DDMfVXNcoUkYND5b8w2Qj+oIJbNJ0Q2 rtjfYfTI6HCtMUK4bsxDzK7E3+bEJY3DRO5d3BHdevKwc0xODfBj30= 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:message-id:mime-version:content-type; s= default; bh=PYR6CimQMcajMhAh/Nhb1hDlev4=; b=WZJ3Un6144OhSiLSXKTK CvkdlmVysRqYUS/u5oRARfC6/32nW7B45tE1ZmVD2n0jRYMdgN6OT7N4QrYFPgOc kMDKbWmJoAowDru9L6yIwbkXvhgRQK0GZeWRyIvgtvPcRabLaUBzROOAVyARVXhv y7buiEKgrWBiNOgGxCCmpW8= Received: (qmail 16057 invoked by alias); 24 Nov 2014 16:18:15 -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 16047 invoked by uid 89); 24 Nov 2014 16:18:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 24 Nov 2014 16:18:08 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id A83C0544456; Mon, 24 Nov 2014 17:18:04 +0100 (CET) Date: Mon, 24 Nov 2014 17:18:04 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Improve inliner's handling of aliases Message-ID: <20141124161804.GB19451@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, the original update of inliner for aliases contined some lazyness. This patch fixes I think last remainder of it where inliner did not remove symbol with aliases on it. This is more important now when ICF uses aliases quite often. Bootstrapped/regtested x86_64-linux, comitted. PR ipa/63671 * ipa-inline-transform.c (can_remove_node_now_p_1): Handle alises and -fno-devirtualize more carefully. (can_remove_node_now_p): Update. Index: ipa-inline-transform.c =================================================================== --- ipa-inline-transform.c (revision 217980) +++ ipa-inline-transform.c (working copy) @@ -93,19 +93,28 @@ update_noncloned_frequencies (struct cgr copy of function was removed. */ static bool -can_remove_node_now_p_1 (struct cgraph_node *node) +can_remove_node_now_p_1 (struct cgraph_node *node, struct cgraph_edge *e) { + ipa_ref *ref; + + FOR_EACH_ALIAS (node, ref) + { + cgraph_node *alias = dyn_cast (ref->referring); + if ((alias->callers && alias->callers != e) + || !can_remove_node_now_p_1 (alias, e)) + return false; + } /* FIXME: When address is taken of DECL_EXTERNAL function we still can remove its offline copy, but we would need to keep unanalyzed node in the callgraph so references can point to it. */ return (!node->address_taken - && !node->has_aliases_p () && node->can_remove_if_no_direct_calls_p () /* Inlining might enable more devirtualizing, so we want to remove those only after all devirtualizable virtual calls are processed. Lacking may edges in callgraph we just preserve them post inlining. */ - && !DECL_VIRTUAL_P (node->decl) + && (!DECL_VIRTUAL_P (node->decl) + || !opt_for_fn (node->decl, flag_devirtualize)) /* During early inlining some unanalyzed cgraph nodes might be in the callgraph and they might reffer the function in question. */ && !cgraph_new_nodes.exists ()); @@ -119,7 +128,7 @@ static bool can_remove_node_now_p (struct cgraph_node *node, struct cgraph_edge *e) { struct cgraph_node *next; - if (!can_remove_node_now_p_1 (node)) + if (!can_remove_node_now_p_1 (node, e)) return false; /* When we see same comdat group, we need to be sure that all @@ -128,9 +137,13 @@ can_remove_node_now_p (struct cgraph_nod return true; for (next = dyn_cast (node->same_comdat_group); next != node; next = dyn_cast (next->same_comdat_group)) - if ((next->callers && next->callers != e) - || !can_remove_node_now_p_1 (next)) - return false; + { + if (next->alias) + continue; + if ((next->callers && next->callers != e) + || !can_remove_node_now_p_1 (next, e)) + return false; + } return true; }