From patchwork Tue May 3 18:09:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 618118 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 3qzq2y05Rzz9t3q for ; Wed, 4 May 2016 04:10:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=cBu9mdgV; dkim-atps=neutral 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=ZusUj/yO2eGkV6a3jKK5pQquNTFiqJ5yUVAjnEzo4AKeYEZjTJfCK BXvu6UlQ0AdPGIppTYwVFumlHyWALCbyYp6KAW2lZw4waYhu76DNF6c8K7rEn3aU J5bJSR2uKCZssb+VNsROeWANYijPDuqzMq76paut1G0rzIDjvS3s4s= 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=VqNmFXpGG9fo1PfUtiF2AlsVAjc=; b=cBu9mdgVLQ5Ps10iJD8L EeDulpK2oqq/mTP2vNOAantHN6HhjFA4Q7UEBMBPEheLZdZgpQ5Ev4i+qf1BluEe FhpbkVjR3cA7w7CXT56qrtrkaTN6gTicKmftn7tiJFPzhCGhmn32PQIgewjWcZ9B L5lIFPGfvWa9sX5Rbmvs9yw= Received: (qmail 102817 invoked by alias); 3 May 2016 18:10:06 -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 102808 invoked by uid 89); 3 May 2016 18:10:05 -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, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Early, translated, 2686, 2688 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; Tue, 03 May 2016 18:10:03 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id A88BC542DA5; Tue, 3 May 2016 20:09:59 +0200 (CEST) Date: Tue, 3 May 2016 20:09:59 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Cleanup call_stmt_cannot_inline_p wrt inline_failed Message-ID: <20160503180958.GB83158@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, call_stmt_cannot_inline_p ultimately translated into setting inline_failed to CIF_MISMATCHED_ARGUMENTS. This is not always accurate because the flag is set for multiple reasons. THis patch makes it possible to simply set inline_failed to any of the CIF_FATAL_ERROR codes and inliner won't try to inline it. THis makes call_stmt_cannot_inline_p more or less redundant, but I kept for for a time being because it is currently used by ipa propagation, too. I will try to untangle this incrementally. With this patch at least the inline_failed reason is correct for thunks and other cases. Bootstrapped/regtested x86_64-linux, will commit it after further testing on Firefox. Honza * cgraph.c (symbol_table::create_edge): Set inline_failed. (cgraph_edge::make_direct): Likewise. (cgraph_edge::dump_edge_flags): Dump call_stmt_cannot_inline_p. * cgraphclones.c (duplicate_thunk_for_node): Set inline_failed. * cif-code.def (CIF_LTO_MISMATCHED_DECLARATIONS): New code (CIF_THUNK): New code. * ipa-inline-analysis.c (initialize_inline_failed): Preserve CIF_FINAL_ERROR codes; do not deal with call_stmt_cannot_inline_p. (compute_inline_parameters): Set inline_failed for thunks. (inline_analyze_function): Cleanup. * ipa-inline.c (can_inline_edge_p): Do not deal with call_stmt_cannot_inline_p. (can_early_inline_edge_p): Likewise. (early_inliner): Initialize inline_failed. * lto-cgraph.c (lto_output_edge): Sanity check inline_failed. * lto-symtab.c (lto_cgraph_replace_node): Initialize inline_failed. Index: cgraph.c =================================================================== --- cgraph.c (revision 235830) +++ cgraph.c (working copy) @@ -859,9 +859,15 @@ symbol_table::create_edge (cgraph_node * && callee && callee->decl && !gimple_check_call_matching_types (call_stmt, callee->decl, false)) - edge->call_stmt_cannot_inline_p = true; + { + edge->inline_failed = CIF_MISMATCHED_ARGUMENTS; + edge->call_stmt_cannot_inline_p = true; + } else - edge->call_stmt_cannot_inline_p = false; + { + edge->inline_failed = CIF_FUNCTION_NOT_CONSIDERED; + edge->call_stmt_cannot_inline_p = false; + } edge->indirect_info = NULL; edge->indirect_inlining_edge = 0; @@ -1240,10 +1246,12 @@ cgraph_edge::make_direct (cgraph_node *c /* Insert to callers list of the new callee. */ edge->set_callee (callee); - if (call_stmt) - call_stmt_cannot_inline_p - = !gimple_check_call_matching_types (call_stmt, callee->decl, - false); + if (call_stmt + && !gimple_check_call_matching_types (call_stmt, callee->decl, false)) + { + call_stmt_cannot_inline_p = true; + inline_failed = CIF_MISMATCHED_ARGUMENTS; + } /* We need to re-determine the inlining status of the edge. */ initialize_inline_failed (edge); @@ -1996,6 +2004,8 @@ cgraph_edge::dump_edge_flags (FILE *f) fprintf (f, "(speculative) "); if (!inline_failed) fprintf (f, "(inlined) "); + if (call_stmt_cannot_inline_p) + fprintf (f, "(call_stmt_cannot_inline_p) "); if (indirect_inlining_edge) fprintf (f, "(indirect_inlining) "); if (count) Index: cgraphclones.c =================================================================== --- cgraphclones.c (revision 235830) +++ cgraphclones.c (working copy) @@ -338,6 +338,7 @@ duplicate_thunk_for_node (cgraph_node *t cgraph_edge *e = new_thunk->create_edge (node, NULL, 0, CGRAPH_FREQ_BASE); e->call_stmt_cannot_inline_p = true; + e->inline_failed = CIF_THUNK; symtab->call_edge_duplication_hooks (thunk->callees, e); symtab->call_cgraph_duplication_hooks (thunk, new_thunk); return new_thunk; Index: cif-code.def =================================================================== --- cif-code.def (revision 235830) +++ cif-code.def (working copy) @@ -92,8 +92,12 @@ DEFCIFCODE(MISMATCHED_ARGUMENTS, CIF_FIN N_("mismatched arguments")) /* Caller and callee disagree on the arguments. */ -DEFCIFCODE(THUNK, CIF_FINAL_ERROR, - N_("thunk call")) +DEFCIFCODE(LTO_MISMATCHED_DECLARATIONS, CIF_FINAL_ERROR, + N_("mismatched declarations during linktime optimization")) + +/* Caller is thunk. */ +DEFCIFCODE(THUNK, CIF_FINAL_ERROR, + N_("thunk call")) /* Call was originally indirect. */ DEFCIFCODE(ORIGINALLY_INDIRECT_CALL, CIF_FINAL_NORMAL, Index: ipa-inline-analysis.c =================================================================== --- ipa-inline-analysis.c (revision 235830) +++ ipa-inline-analysis.c (working copy) @@ -1490,19 +1490,23 @@ initialize_inline_failed (struct cgraph_ { struct cgraph_node *callee = e->callee; - if (e->indirect_unknown_callee) + if (e->inline_failed && e->inline_failed != CIF_BODY_NOT_AVAILABLE + && cgraph_inline_failed_type (e->inline_failed) == CIF_FINAL_ERROR) + ; + else if (e->indirect_unknown_callee) e->inline_failed = CIF_INDIRECT_UNKNOWN_CALL; else if (!callee->definition) e->inline_failed = CIF_BODY_NOT_AVAILABLE; else if (callee->local.redefined_extern_inline) e->inline_failed = CIF_REDEFINED_EXTERN_INLINE; - else if (e->call_stmt_cannot_inline_p) - e->inline_failed = CIF_MISMATCHED_ARGUMENTS; else if (cfun && fn_contains_cilk_spawn_p (cfun)) /* We can't inline if the function is spawing a function. */ - e->inline_failed = CIF_FUNCTION_NOT_INLINABLE; + e->inline_failed = CIF_CILK_SPAWN; else e->inline_failed = CIF_FUNCTION_NOT_CONSIDERED; + gcc_checking_assert (!e->call_stmt_cannot_inline_p + || cgraph_inline_failed_type (e->inline_failed) + == CIF_FINAL_ERROR); } /* Callback of walk_aliased_vdefs. Flags that it has been invoked to the @@ -2925,7 +2929,7 @@ compute_inline_parameters (struct cgraph struct predicate t = true_predicate (); info->inlinable = 0; - node->callees->call_stmt_cannot_inline_p = true; + node->callees->inline_failed = CIF_THUNK; node->local.can_change_signature = false; es->call_stmt_time = 1; es->call_stmt_size = 1; @@ -4107,17 +4111,9 @@ inline_analyze_function (struct cgraph_n { struct cgraph_edge *e; for (e = node->callees; e; e = e->next_callee) - { - if (e->inline_failed == CIF_FUNCTION_NOT_CONSIDERED) - e->inline_failed = CIF_FUNCTION_NOT_OPTIMIZED; - e->call_stmt_cannot_inline_p = true; - } + e->inline_failed = CIF_FUNCTION_NOT_OPTIMIZED; for (e = node->indirect_calls; e; e = e->next_callee) - { - if (e->inline_failed == CIF_FUNCTION_NOT_CONSIDERED) - e->inline_failed = CIF_FUNCTION_NOT_OPTIMIZED; - e->call_stmt_cannot_inline_p = true; - } + e->inline_failed = CIF_FUNCTION_NOT_OPTIMIZED; } pop_cfun (); Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 235830) +++ ipa-inline.c (working copy) @@ -335,12 +335,10 @@ can_inline_edge_p (struct cgraph_edge *e e->inline_failed = CIF_OVERWRITABLE; inlinable = false; } + /* All edges with call_stmt_cannot_inline_p should have inline_failed + initialized to one of FINAL_ERROR reasons. */ else if (e->call_stmt_cannot_inline_p) - { - if (e->inline_failed != CIF_FUNCTION_NOT_OPTIMIZED) - e->inline_failed = e->caller->thunk.thunk_p ? CIF_THUNK : CIF_MISMATCHED_ARGUMENTS; - inlinable = false; - } + gcc_unreachable (); /* Don't inline if the functions have different EH personalities. */ else if (DECL_FUNCTION_PERSONALITY (caller->decl) && DECL_FUNCTION_PERSONALITY (callee->decl) @@ -529,6 +527,8 @@ can_early_inline_edge_p (struct cgraph_e /* Early inliner might get called at WPA stage when IPA pass adds new function. In this case we can not really do any of early inlining because function bodies are missing. */ + if (cgraph_inline_failed_type (e->inline_failed) == CIF_FINAL_ERROR) + return false; if (!gimple_has_body_p (callee->decl)) { e->inline_failed = CIF_BODY_NOT_AVAILABLE; @@ -2741,7 +2741,10 @@ early_inliner (function *fun) if (edge->callee->decl && !gimple_check_call_matching_types ( edge->call_stmt, edge->callee->decl, false)) - edge->call_stmt_cannot_inline_p = true; + { + edge->inline_failed = CIF_MISMATCHED_ARGUMENTS; + edge->call_stmt_cannot_inline_p = true; + } } if (iterations < PARAM_VALUE (PARAM_EARLY_INLINER_MAX_ITERATIONS) - 1) inline_update_overall_summary (node); Index: lto/lto-symtab.c =================================================================== --- lto/lto-symtab.c (revision 235830) +++ lto/lto-symtab.c (working copy) @@ -81,7 +81,10 @@ lto_cgraph_replace_node (struct cgraph_n ??? We really need a way to match function signatures for ABI compatibility and perform related promotions at inlining time. */ if (!compatible_p) - e->call_stmt_cannot_inline_p = 1; + { + e->inline_failed = CIF_LTO_MISMATCHED_DECLARATIONS; + e->call_stmt_cannot_inline_p = 1; + } } /* Redirect incomming references. */ prevailing_node->clone_referring (node); Index: lto-cgraph.c =================================================================== --- lto-cgraph.c (revision 235830) +++ lto-cgraph.c (working copy) @@ -268,6 +268,8 @@ lto_output_edge (struct lto_simple_outpu bp_pack_value (&bp, edge->indirect_inlining_edge, 1); bp_pack_value (&bp, edge->speculative, 1); bp_pack_value (&bp, edge->call_stmt_cannot_inline_p, 1); + gcc_assert (!edge->call_stmt_cannot_inline_p + || edge->inline_failed != CIF_BODY_NOT_AVAILABLE); bp_pack_value (&bp, edge->can_throw_external, 1); bp_pack_value (&bp, edge->in_polymorphic_cdtor, 1); if (edge->indirect_unknown_callee)