From patchwork Sun Nov 16 20:52:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 411351 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 CBE8D140100 for ; Mon, 17 Nov 2014 07:52:18 +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=mNbFubUgtt+ZzW2AYpNAoveUUA1HHHgWNLg1/O/xhRUkUg5fxBHHA bSe+2OZ6Xn6DgCCxE2UtQMj1/g4TunzDj7/xQA2jmG+k8fEElQm6N3n3f46Or4Rj klzpAAV+iglio0ztiUC8hNewV1BzBFU6Km0BYeS1/t4vpb9ukHpmdg= 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=83ce0uuPa46rQR15hx4BRMR9Sx8=; b=aOWgpNyF19Xzgv+Gj0s9 JXfEyzu0lANFNkmivf6KU+tqufjqImvtBaGJ9v2IOR1pc97Al40HQ0w/cwBMryfF mJ263aR4y/IwG+XBENP0A/0g/k2DPgJ5UbQFq0M1h/jnXrnTfvygOfKrMOenSbXz MWALmbj2AS76WPNFO76voJo= Received: (qmail 18161 invoked by alias); 16 Nov 2014 20:52:12 -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 18149 invoked by uid 89); 16 Nov 2014 20:52:11 -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; Sun, 16 Nov 2014 20:52:11 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 43E1054096D; Sun, 16 Nov 2014 21:52:07 +0100 (CET) Date: Sun, 16 Nov 2014 21:52:07 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Audit cgraph.c for optimization attributes Message-ID: <20141116205207.GD13765@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, this patch updates cgraph.c. To make flag_devirtualize fully per-function basis, we will need some infastructure to figure out if it is used at all and if the type inheritance graph construction should be done (or do it uncondtionally). Adding proper opt_for_fn tests at least makes it possible to disable devirtualization at function granuality. cgraph_edge::maybe_hot_p may be cleaned up if profile_status was moved from cfun->cfg to callgraph node (where it belongs, but it was not placed there for performance reasons that are gone since last release). Bootstrapped/regtested x86_64-linux, will commit it after testing on Firefox LTO. * cgraph.c (symbol_table::create_edge): Use opt_for_fn. (cgraph_node::cannot_return_p): Likewise. (cgraph_edge::cannot_lead_to_return_p): Likewise. (cgraph_edge::maybe_hot_p): Likewise. Index: cgraph.c =================================================================== --- cgraph.c (revision 217633) +++ cgraph.c (working copy) @@ -859,7 +859,8 @@ symbol_table::create_edge (cgraph_node * edge->indirect_inlining_edge = 0; edge->speculative = false; edge->indirect_unknown_callee = indir_unknown_callee; - if (flag_devirtualize && call_stmt && DECL_STRUCT_FUNCTION (caller->decl)) + if (opt_for_fn (edge->caller->decl, flag_devirtualize) + && call_stmt && DECL_STRUCT_FUNCTION (caller->decl)) edge->in_polymorphic_cdtor = decl_maybe_in_construction_p (NULL, NULL, call_stmt, caller->decl); @@ -2374,7 +2375,7 @@ bool cgraph_node::cannot_return_p (void) { int flags = flags_from_decl_or_type (decl); - if (!flag_exceptions) + if (!opt_for_fn (decl, flag_exceptions)) return (flags & ECF_NORETURN) != 0; else return ((flags & (ECF_NORETURN | ECF_NOTHROW)) @@ -2394,7 +2395,7 @@ cgraph_edge::cannot_lead_to_return_p (vo if (indirect_unknown_callee) { int flags = indirect_info->ecf_flags; - if (!flag_exceptions) + if (!opt_for_fn (caller->decl, flag_exceptions)) return (flags & ECF_NORETURN) != 0; else return ((flags & (ECF_NORETURN | ECF_NOTHROW)) @@ -2409,7 +2410,9 @@ cgraph_edge::cannot_lead_to_return_p (vo bool cgraph_edge::maybe_hot_p (void) { - if (profile_info && flag_branch_probabilities + /* TODO: Export profile_status from cfun->cfg to cgraph_node. */ + if (profile_info + && opt_for_fn (caller->decl, flag_branch_probabilities) && !maybe_hot_count_p (NULL, count)) return false; if (caller->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED @@ -2420,17 +2423,18 @@ cgraph_edge::maybe_hot_p (void) && (callee && callee->frequency <= NODE_FREQUENCY_EXECUTED_ONCE)) return false; - if (optimize_size) return false; + if (opt_for_fn (caller->decl, optimize_size)) + return false; if (caller->frequency == NODE_FREQUENCY_HOT) return true; if (caller->frequency == NODE_FREQUENCY_EXECUTED_ONCE && frequency < CGRAPH_FREQ_BASE * 3 / 2) return false; - if (flag_guess_branch_prob) + if (opt_for_fn (caller->decl, flag_guess_branch_prob)) { if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0 || frequency <= (CGRAPH_FREQ_BASE - / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION))) + / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION))) return false; } return true;