From patchwork Sun Oct 27 08:13:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1184932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-511845-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="W8qnWR7F"; 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 4719bQ0jjWz9sP4 for ; Sun, 27 Oct 2019 19:13:37 +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=oyLcU7NOZ1iZpzRJuudagHnlAnyMSnoqBUi95MbTtBbMey+yGVGj8 v8U0KE2ARts/g2hEbrSkkn6jngKtseHXNkJSBtDbk3AITG9uKcDfatZFOEa+RWZJ b8bSLF3BlJTASRd4P+htUT6f0MkW9RN5VSqHciDRqr/us2dszrXvJw= 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=7AixoVRK0ZRhoJHWc+WiGJL2Ywc=; b=W8qnWR7FYNEvj/6rDeJ7 3O8MRxzk3H1HdJjAcCGVJ7qksQsuJ2bi5wghCtwc9u8PfkGIaOK7WDvdeSvcbyp4 agjLVX/u4I34kpGBST1KBFDoYU3REl5cFDI3xCqjcjVxzc3XsGMq/gYhIkxMXMDx Xy2Asx77Ur6dduyCQkH4XHc= Received: (qmail 15490 invoked by alias); 27 Oct 2019 08:13:31 -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 15480 invoked by uid 89); 27 Oct 2019 08:13:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=ipa-fnsummary.c, sk:ipa_edg, sk:ipa_fn_, ipafnsummaryc 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 ESMTP; Sun, 27 Oct 2019 08:13:29 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id E2B67280821; Sun, 27 Oct 2019 09:13:26 +0100 (CET) Date: Sun, 27 Oct 2019 09:13:26 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, mjambor@suse.cz Subject: Free ipa-prop edge summaries for inline calls Message-ID: <20191027081326.v3j23qcswowebegr@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, this patch makes ipa-prop to free edge summaries (jump functions) for calls which has been inlined because they are no longer useful. The main change is to change IPA_EDGE_REF from get_create to get and thus we need to watch for missing summaires at some places so combining -O0 and -O2 code works. Bootstrapped/regtested x86_64-linux, comitted. * ipa-cp.c (propagate_constants_across_call): If args are not available just drop everything to varying. (find_aggregate_values_for_callers_subset): Watch for missing edge summary. (find_more_scalar_values_for_callers_subs): Likewise. * ipa-prop.c (ipa_compute_jump_functions_for_edge, update_jump_functions_after_inlining, propagate_controlled_uses): Watch for missing summaries. (ipa_propagate_indirect_call_infos): Remove summary after propagation is finished. (ipa_write_node_info): Watch for missing summaries. (ipa_read_edge_info): Create new ref. (ipa_edge_args_sum_t): Add remove. (IPA_EDGE_REF_GET_CREATE): New macro. * ipa-fnsummary.c (evaluate_properties_for_edge): Watch for missing edge summary. (remap_edge_change_prob): Likewise. Index: ipa-cp.c =================================================================== --- ipa-cp.c (revision 277474) +++ ipa-cp.c (working copy) @@ -2309,10 +2309,17 @@ propagate_constants_across_call (struct callee_info = IPA_NODE_REF (callee); args = IPA_EDGE_REF (cs); - args_count = ipa_get_cs_argument_count (args); parms_count = ipa_get_param_count (callee_info); if (parms_count == 0) return false; + if (!args) + { + for (i = 0; i < parms_count; i++) + ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info, + i)); + return ret; + } + args_count = ipa_get_cs_argument_count (args); /* If this call goes through a thunk we must not propagate to the first (0th) parameter. However, we might need to uncover a thunk from below a series @@ -4066,7 +4073,8 @@ find_more_scalar_values_for_callers_subs if (IPA_NODE_REF (cs->caller)->node_dead) continue; - if (i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs)) + if (!IPA_EDGE_REF (cs) + || i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs)) || (i == 0 && call_passes_through_thunk_p (cs))) { @@ -4135,7 +4143,8 @@ find_more_contexts_for_caller_subset (cg FOR_EACH_VEC_ELT (callers, j, cs) { - if (i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs))) + if (!IPA_EDGE_REF (cs) + || i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs))) return; ipa_jump_func *jfunc = ipa_get_ith_jump_func (IPA_EDGE_REF (cs), i); @@ -4451,6 +4460,11 @@ find_aggregate_values_for_callers_subset FOR_EACH_VEC_ELT (callers, j, cs) { + if (!IPA_EDGE_REF (cs)) + { + count = 0; + break; + } int c = ipa_get_cs_argument_count (IPA_EDGE_REF (cs)); if (c < count) count = c; Index: ipa-fnsummary.c =================================================================== --- ipa-fnsummary.c (revision 277474) +++ ipa-fnsummary.c (working copy) @@ -452,6 +452,7 @@ evaluate_properties_for_edge (struct cgr class ipa_fn_summary *info = ipa_fn_summaries->get (callee); vec known_vals = vNULL; vec known_aggs = vNULL; + class ipa_edge_args *args; if (clause_ptr) *clause_ptr = inline_p ? 0 : 1 << predicate::not_inlined_condition; @@ -462,10 +463,10 @@ evaluate_properties_for_edge (struct cgr if (ipa_node_params_sum && !e->call_stmt_cannot_inline_p - && ((clause_ptr && info->conds) || known_vals_ptr || known_contexts_ptr)) + && ((clause_ptr && info->conds) || known_vals_ptr || known_contexts_ptr) + && (args = IPA_EDGE_REF (e)) != NULL) { class ipa_node_params *caller_parms_info, *callee_pi; - class ipa_edge_args *args = IPA_EDGE_REF (e); class ipa_call_summary *es = ipa_call_summaries->get (e); int i, count = ipa_get_cs_argument_count (args); @@ -3160,6 +3161,8 @@ remap_edge_change_prob (struct cgraph_ed { int i; class ipa_edge_args *args = IPA_EDGE_REF (edge); + if (!args) + return; class ipa_call_summary *es = ipa_call_summaries->get (edge); class ipa_call_summary *inlined_es = ipa_call_summaries->get (inlined_edge); Index: ipa-prop.c =================================================================== --- ipa-prop.c (revision 277474) +++ ipa-prop.c (working copy) @@ -1854,7 +1854,7 @@ ipa_compute_jump_functions_for_edge (str struct cgraph_edge *cs) { class ipa_node_params *info = IPA_NODE_REF (cs->caller); - class ipa_edge_args *args = IPA_EDGE_REF (cs); + class ipa_edge_args *args = IPA_EDGE_REF_GET_CREATE (cs); gcall *call = cs->call_stmt; int n, arg_num = gimple_call_num_args (call); bool useful_context = false; @@ -2652,6 +2652,8 @@ update_jump_functions_after_inlining (st { class ipa_edge_args *top = IPA_EDGE_REF (cs); class ipa_edge_args *args = IPA_EDGE_REF (e); + if (!args) + return; int count = ipa_get_cs_argument_count (args); int i; @@ -3575,6 +3577,8 @@ static void propagate_controlled_uses (struct cgraph_edge *cs) { class ipa_edge_args *args = IPA_EDGE_REF (cs); + if (!args) + return; struct cgraph_node *new_root = cs->caller->global.inlined_to ? cs->caller->global.inlined_to : cs->caller; class ipa_node_params *new_root_info = IPA_NODE_REF (new_root); @@ -3702,6 +3706,7 @@ ipa_propagate_indirect_call_infos (struc propagate_controlled_uses (cs); changed = propagate_info_to_inlined_callees (cs, cs->callee, new_edges); + ipa_edge_args_sum->remove (cs); return changed; } @@ -4380,6 +4385,12 @@ ipa_write_node_info (struct output_block { class ipa_edge_args *args = IPA_EDGE_REF (e); + if (!args) + { + streamer_write_uhwi (ob, 0); + continue; + } + streamer_write_uhwi (ob, ipa_get_cs_argument_count (args) * 2 + (args->polymorphic_call_contexts != NULL)); @@ -4393,15 +4404,19 @@ ipa_write_node_info (struct output_block for (e = node->indirect_calls; e; e = e->next_callee) { class ipa_edge_args *args = IPA_EDGE_REF (e); - - streamer_write_uhwi (ob, - ipa_get_cs_argument_count (args) * 2 - + (args->polymorphic_call_contexts != NULL)); - for (j = 0; j < ipa_get_cs_argument_count (args); j++) + if (!args) + streamer_write_uhwi (ob, 0); + else { - ipa_write_jump_function (ob, ipa_get_ith_jump_func (args, j)); - if (args->polymorphic_call_contexts != NULL) - ipa_get_ith_polymorhic_call_context (args, j)->stream_out (ob); + streamer_write_uhwi (ob, + ipa_get_cs_argument_count (args) * 2 + + (args->polymorphic_call_contexts != NULL)); + for (j = 0; j < ipa_get_cs_argument_count (args); j++) + { + ipa_write_jump_function (ob, ipa_get_ith_jump_func (args, j)); + if (args->polymorphic_call_contexts != NULL) + ipa_get_ith_polymorhic_call_context (args, j)->stream_out (ob); + } } ipa_write_indirect_edge_info (ob, e); } @@ -4422,7 +4437,7 @@ ipa_read_edge_info (class lto_input_bloc return; if (prevails && e->possibly_call_in_translation_unit_p ()) { - class ipa_edge_args *args = IPA_EDGE_REF (e); + class ipa_edge_args *args = IPA_EDGE_REF_GET_CREATE (e); vec_safe_grow_cleared (args->jump_functions, count); if (contexts_computed) vec_safe_grow_cleared (args->polymorphic_call_contexts, count); Index: ipa-prop.h =================================================================== --- ipa-prop.h (revision 277482) +++ ipa-prop.h (working copy) @@ -640,6 +640,11 @@ class GTY((user)) ipa_edge_args_sum_t : ipa_edge_args_sum_t (symbol_table *table, bool ggc) : call_summary (table, ggc) { } + void remove (cgraph_edge *edge) + { + call_summary ::remove (edge); + } + /* Hook that is called by summary when an edge is removed. */ virtual void remove (cgraph_edge *cs, ipa_edge_args *args); /* Hook that is called by summary when an edge is duplicated. */ @@ -679,7 +684,8 @@ extern GTY(()) function_summary get_create (NODE)) -#define IPA_EDGE_REF(EDGE) (ipa_edge_args_sum->get_create (EDGE)) +#define IPA_EDGE_REF(EDGE) (ipa_edge_args_sum->get (EDGE)) +#define IPA_EDGE_REF_GET_CREATE(EDGE) (ipa_edge_args_sum->get_create (EDGE)) /* This macro checks validity of index returned by ipa_get_param_decl_index function. */ #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)