From patchwork Mon Jun 30 11:49:20 2014 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: 365551 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 A4AC31400FA for ; Mon, 30 Jun 2014 21:49:37 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=RAiZ+7B+jsgpiiIiI Ixg2EtYYJBntFVs6N5SIzOBsaT3LMJHTRcXUXcojpiwOI2dC1LJFNLSbZ19XeGsj gpQaSHddM94S4w0Szg3c1a5FGJ7HARKat/LdEmnn9ifEqARu2w3MkfJtjxex46dK MCdChVgQ5xXMswqeQnpz/fF/dM= 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 :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=cciTp4UK3IJfW/sWYUEfcO1 20ww=; b=AFMwRLp6sYSdXH53NeKNY7QI184sBTEyd3w3qA7/1iq17oFa4+XM98+ n6CLvDrV+AkXYZaT2hIfqQe2MtTlODFE0Cs/M1m/aHWp+Y8zeFPFHGG28pg+K9c3 eIddc5lO42ooBb2j5el0uc9oRLqOnhUJoD1a+XV0IrwEW/GhPgTo= Received: (qmail 17309 invoked by alias); 30 Jun 2014 11:49:30 -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 17287 invoked by uid 89); 30 Jun 2014 11:49:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 30 Jun 2014 11:49:24 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E6819ACC1 for ; Mon, 30 Jun 2014 11:49:21 +0000 (UTC) Message-ID: <53B14EC0.1080509@suse.cz> Date: Mon, 30 Jun 2014 13:49:20 +0200 From: =?windows-1252?Q?Martin_Li=9Aka?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 2/5] Existing call graph infrastructure enhancement References: <47303faf697c5f537d471e88d3c946c5a1d04f6e.1402913001.git.mliska@suse.cz> <53A09E46.5080507@redhat.com> In-Reply-To: <53A09E46.5080507@redhat.com> X-IsSubscribed: yes On 06/17/2014 10:00 PM, Jeff Law wrote: > On 06/13/14 04:26, mliska wrote: >> Hi, >> this small patch prepares remaining needed infrastructure for the new pass. >> >> Changelog: >> >> 2014-06-13 Martin Liska >> Honza Hubicka >> >> * ipa-utils.h (polymorphic_type_binfo_p): Function marked external >> instead of static. >> * ipa-devirt.c (polymorphic_type_binfo_p): Likewise. >> * ipa-prop.h (count_formal_params): Likewise. >> * ipa-prop.c (count_formal_params): Likewise. >> * ipa-utils.c (ipa_merge_profiles): Be more tolerant if we merge >> profiles for semantically equivalent functions. >> * passes.c (do_per_function): If we load body of a function during WPA, >> this condition should behave same. >> * varpool.c (ctor_for_folding): More tolerant assert for variable >> aliases created during WPA. > Presumably we don't have any useful way to merge the cases where we have provides for SRC & DST in ipa_merge_profiles or even to guess which is more useful when presented with both? Does it make sense to log this into a debugging file when we drop one? Hello, this merge function was written by Honza, what do you think Honza about this note? > I think this patch is fine. If adding logging makes sense, then feel free to do so and consider that trivial change pre-approved. I made a small change to this patch, where I moved 'gsi_next_nonvirtual_phi' from the pass to gimple-iterator.h. Ready for trunk with this change? Thanks, Martin gcc/ChangeLog 2014-06-30 Martin Liska Honza Hubicka * gimple-iterator.h (gsi_next_nonvirtual_phi): New function. * ipa-utils.h (polymorphic_type_binfo_p): Function marked external instead of static. * ipa-devirt.c (polymorphic_type_binfo_p): Likewise. * ipa-prop.h (count_formal_params): Likewise. * ipa-prop.c (count_formal_params): Likewise. * ipa-utils.c (ipa_merge_profiles): Be more tolerant if we merge profiles for semantically equivalent functions. * passes.c (do_per_function): If we load body of a function during WPA, this condition should behave same. * varpool.c (ctor_for_folding): More tolerant assert for variable aliases created during WPA. > > Jeff > diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h index 909d58b..47168b9 100644 --- a/gcc/gimple-iterator.h +++ b/gcc/gimple-iterator.h @@ -281,6 +281,30 @@ gsi_last_nondebug_bb (basic_block bb) return i; } +/* Iterates I statement iterator to the next non-virtual statement. */ + +static inline void +gsi_next_nonvirtual_phi (gimple_stmt_iterator *i) +{ + gimple phi; + + if (gsi_end_p (*i)) + return; + + phi = gsi_stmt (*i); + gcc_assert (phi != NULL); + + while (virtual_operand_p (gimple_phi_result (phi))) + { + gsi_next (i); + + if (gsi_end_p (*i)) + return; + + phi = gsi_stmt (*i); + } +} + /* Return the basic block associated with this iterator. */ static inline basic_block diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index d6b85bf..2f62323 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -176,7 +176,7 @@ struct GTY(()) odr_type_d inheritance (because vtables are shared). Look up the BINFO of type and check presence of its vtable. */ -static inline bool +bool polymorphic_type_binfo_p (tree binfo) { /* See if BINFO's type has an virtual table associtated with it. */ diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 68efc77..bb2fbf3 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -210,7 +210,7 @@ ipa_populate_param_decls (struct cgraph_node *node, /* Return how many formal parameters FNDECL has. */ -static inline int +int count_formal_params (tree fndecl) { tree parm; diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 8886e93..bc6249e 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -529,6 +529,7 @@ void ipa_free_all_edge_args (void); void ipa_free_all_structures_after_ipa_cp (void); void ipa_free_all_structures_after_iinln (void); void ipa_register_cgraph_hooks (void); +int count_formal_params (tree fndecl); /* This function ensures the array of node param infos is big enough to accommodate a structure for all nodes and reallocates it if not. */ diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c index c191210..d58b170 100644 --- a/gcc/ipa-utils.c +++ b/gcc/ipa-utils.c @@ -660,13 +660,8 @@ ipa_merge_profiles (struct cgraph_node *dst, if (dst->tp_first_run > src->tp_first_run && src->tp_first_run) dst->tp_first_run = src->tp_first_run; - if (src->profile_id) - { - if (!dst->profile_id) - dst->profile_id = src->profile_id; - else - gcc_assert (src->profile_id == dst->profile_id); - } + if (src->profile_id && !dst->profile_id) + dst->profile_id = src->profile_id; if (!dst->count) return; diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h index a2c985a..996249a 100644 --- a/gcc/ipa-utils.h +++ b/gcc/ipa-utils.h @@ -72,6 +72,8 @@ struct odr_type_d; typedef odr_type_d *odr_type; void build_type_inheritance_graph (void); void update_type_inheritance_graph (void); +bool polymorphic_type_binfo_p (tree binfo); + vec possible_polymorphic_call_targets (tree, HOST_WIDE_INT, ipa_polymorphic_call_context, diff --git a/gcc/passes.c b/gcc/passes.c index 91b644e..cd88823 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -1506,7 +1506,7 @@ do_per_function (void (*callback) (function *, void *data), void *data) { struct cgraph_node *node; FOR_EACH_DEFINED_FUNCTION (node) - if (node->analyzed && gimple_has_body_p (node->decl) + if (node->analyzed && (gimple_has_body_p (node->decl) && !in_lto_p) && (!node->clone_of || node->decl != node->clone_of->decl)) callback (DECL_STRUCT_FUNCTION (node->decl), data); } diff --git a/gcc/varpool.c b/gcc/varpool.c index 04ac870..59f4f8a 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -301,6 +301,7 @@ ctor_for_folding (tree decl) if (decl != real_decl) { gcc_assert (!DECL_INITIAL (decl) + || (node->alias && varpool_alias_target (node) == real_node) || DECL_INITIAL (decl) == error_mark_node); if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))) { -- 1.8.4.5