From patchwork Wed Mar 18 11:03:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 451375 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 40FFA140083 for ; Wed, 18 Mar 2015 22:03:58 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=okSaQaGk; dkim-adsp=none (unprotected policy); 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=DJtuGFPaHI1Sk82CI eKbFT6TZ2L7+BdowUY2forr0auedbpK2Fi/QtyI+9ekvby8A0XgeKPKErAGIZbcd 8lN76RyX7bGNw7X5adddrgP3XqC+q9A00jBP+ge/spINralz/0wdML6MIzY5yESE ZF48Gp16dvef1yEih5CN3qEDR8= 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:cc:subject:references :in-reply-to:content-type; s=default; bh=HJhtxh5uxHiIztJxAO9lgzz XkyM=; b=okSaQaGkVca2WVgZ9AKu8Em6J8LoqG+Zzqw8rWg3rYiNO/c/xxPrezc AB8I4ddTu2gKZbdAmwGjw6QTwJI+25WEj8OCL2YRnb/888s1s2lrs0Yi+BpBiuUW GxDnI2UAUzcbgOG1rsBW+O2ugG1IWU3ZNScmk6v7GMDxsla/U2p0= Received: (qmail 6465 invoked by alias); 18 Mar 2015 11:03:50 -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 6451 invoked by uid 89); 18 Mar 2015 11:03:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Mar 2015 11:03:42 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YYBlB-0006Fg-NW from Tom_deVries@mentor.com ; Wed, 18 Mar 2015 04:03:38 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Wed, 18 Mar 2015 11:03:36 +0000 Message-ID: <55095B84.4070807@mentor.com> Date: Wed, 18 Mar 2015 12:03:32 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Richard Biener CC: Jakub Jelinek , GCC Patches Subject: Re: [PATCH, stage1] Make parloops gate more strict References: <5502BCA2.2010802@mentor.com> <5502C620.1050202@mentor.com> <20150313120756.GC1746@tucnak.redhat.com> <55030211.5060203@mentor.com> In-Reply-To: On 18-03-15 11:16, Richard Biener wrote: > On Fri, Mar 13, 2015 at 4:28 PM, Tom de Vries wrote: >> On 13-03-15 13:36, Richard Biener wrote: >>> >>> On Fri, Mar 13, 2015 at 1:07 PM, Jakub Jelinek wrote: >>>> >>>> On Fri, Mar 13, 2015 at 01:04:57PM +0100, Richard Biener wrote: >>>>> >>>>> Not really (I don't like -fdump-passes ...), but we need to make sure >>>>> that -fdump-passes doesn't crash (because it runs very early and >>>>> with cfun == NULL I think) >>>> >>>> >>>> If it runs with cfun == NULL, then supposedly the gates that are >>>> dependent >>>> on current function should for -fdump-passes purposes also return true >>>> if cfun == NULL (well, of course do all the unconditional checks). >>>> Though of course, with optimize/target attributes this is harder, as >>>> different functions can use different options. >>> >>> >>> Yes, one reason why I think -fdump-passes is just broken >>> implementation-wise. >>> >> >> Atm fdump-passes doesn't run with cfun == NULL. >> >> From pass_manager::dump_passes: >> ... >> FOR_EACH_FUNCTION (n) >> if (DECL_STRUCT_FUNCTION (n->decl)) >> { >> node = n; >> break; >> } >> >> if (!node) >> return; >> >> push_cfun (DECL_STRUCT_FUNCTION (node->decl)); > > Um - this now picks a random function which may be one with > an optimize or target attribute associated to it. > Indeed. Attached patch removes that code, and runs the gates with cfun == NULL for -fdump-passes. It at least builds, and allows us to compile src/gcc/testsuite/gcc.dg/dump-pass.c with -O2 -fdump-passes. Should I bootstrap and reg-test, or do you see a problem with this approach? Thanks, - Tom Fix -fdump-passes --- gcc/bb-reorder.c | 5 +++-- gcc/cprop.c | 8 +++++--- gcc/except.c | 10 +++++----- gcc/gcse.c | 28 ++++++++++++++++------------ gcc/loop-init.c | 11 +++++++---- gcc/omp-low.c | 3 ++- gcc/passes.c | 16 +--------------- gcc/store-motion.c | 10 ++++++---- gcc/tree-chkp-opt.c | 14 ++++++++------ gcc/tree-chkp.c | 11 ++++++----- gcc/tree-complex.c | 3 ++- gcc/tree-eh.c | 10 ++++++++-- gcc/tree-if-conv.c | 6 +++++- gcc/tree-into-ssa.c | 3 ++- gcc/tree-ssa-loop.c | 16 +++++++++++++--- gcc/tree-ssa.c | 3 ++- gcc/tree-stdarg.c | 3 ++- gcc/tree-vect-generic.c | 3 ++- 18 files changed, 95 insertions(+), 68 deletions(-) diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c index c2a3be3..b8f2a4b 100644 --- a/gcc/bb-reorder.c +++ b/gcc/bb-reorder.c @@ -2709,8 +2709,9 @@ pass_partition_blocks::gate (function *fun) /* See gate_handle_reorder_blocks. We should not partition if we are going to omit the reordering. */ && optimize_function_for_speed_p (fun) - && !DECL_COMDAT_GROUP (current_function_decl) - && !user_defined_section_attribute); + && !user_defined_section_attribute + && (fun == NULL + || !DECL_COMDAT_GROUP (current_function_decl))); } unsigned diff --git a/gcc/cprop.c b/gcc/cprop.c index c9fb2fc..bbea008 100644 --- a/gcc/cprop.c +++ b/gcc/cprop.c @@ -1961,9 +1961,11 @@ public: opt_pass * clone () { return new pass_rtl_cprop (m_ctxt); } virtual bool gate (function *fun) { - return optimize > 0 && flag_gcse - && !fun->calls_setjmp - && dbg_cnt (cprop); + return (optimize > 0 + && flag_gcse + && (fun == NULL + || (!fun->calls_setjmp + && dbg_cnt (cprop)))); } virtual unsigned int execute (function *) { return execute_rtl_cprop (); } diff --git a/gcc/except.c b/gcc/except.c index 833ec21..f81ade6 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -2677,14 +2677,14 @@ public: }; // class pass_convert_to_eh_region_ranges bool -pass_convert_to_eh_region_ranges::gate (function *) +pass_convert_to_eh_region_ranges::gate (function *fun) { - /* Nothing to do for SJLJ exceptions or if no regions created. */ - if (cfun->eh->region_tree == NULL) - return false; if (targetm_common.except_unwind_info (&global_options) == UI_SJLJ) return false; - return true; + + /* Nothing to do for SJLJ exceptions or if no regions created. */ + return (fun == NULL + || fun->eh->region_tree != NULL); } } // anon namespace diff --git a/gcc/gcse.c b/gcc/gcse.c index e03b36c..80bdd5f 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -4252,10 +4252,12 @@ public: bool pass_rtl_pre::gate (function *fun) { - return optimize > 0 && flag_gcse - && !fun->calls_setjmp - && optimize_function_for_speed_p (fun) - && dbg_cnt (pre); + return (optimize > 0 + && flag_gcse + && optimize_function_for_speed_p (fun) + && (fun == NULL + || (!fun->calls_setjmp + && dbg_cnt (pre)))); } } // anon namespace @@ -4295,15 +4297,17 @@ public: }; // class pass_rtl_hoist bool -pass_rtl_hoist::gate (function *) +pass_rtl_hoist::gate (function *fun) { - return optimize > 0 && flag_gcse - && !cfun->calls_setjmp - /* It does not make sense to run code hoisting unless we are optimizing - for code size -- it rarely makes programs faster, and can make then - bigger if we did PRE (when optimizing for space, we don't run PRE). */ - && optimize_function_for_size_p (cfun) - && dbg_cnt (hoist); + return (optimize > 0 + && flag_gcse + /* It does not make sense to run code hoisting unless we are optimizing + for code size -- it rarely makes programs faster, and can make then + bigger if we did PRE (when optimizing for space, we don't run PRE). */ + && optimize_function_for_size_p (fun) + && (fun == NULL + || (!fun->calls_setjmp + && dbg_cnt (hoist)))); } } // anon namespace diff --git a/gcc/loop-init.c b/gcc/loop-init.c index c13d360..a000d9d 100644 --- a/gcc/loop-init.c +++ b/gcc/loop-init.c @@ -382,10 +382,13 @@ pass_loop2::gate (function *fun) return true; else { - /* No longer preserve loops, remove them now. */ - fun->curr_properties &= ~PROP_loops; - if (current_loops) - loop_optimizer_finalize (); + if (fun != NULL) + { + /* No longer preserve loops, remove them now. */ + fun->curr_properties &= ~PROP_loops; + if (current_loops) + loop_optimizer_finalize (); + } return false; } } diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 48d73cb..8c57986 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -9557,7 +9557,8 @@ public: /* opt_pass methods: */ virtual bool gate (function *fun) { - return !(fun->curr_properties & PROP_gimple_eomp); + return (fun == NULL + || !(fun->curr_properties & PROP_gimple_eomp)); } virtual unsigned int execute (function *) { return execute_expand_omp (); } diff --git a/gcc/passes.c b/gcc/passes.c index 23a90d9..27c6558 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -944,29 +944,15 @@ dump_passes (void) void pass_manager::dump_passes () const { - struct cgraph_node *n, *node = NULL; - create_pass_tab (); - FOR_EACH_FUNCTION (n) - if (DECL_STRUCT_FUNCTION (n->decl)) - { - node = n; - break; - } - - if (!node) - return; - - push_cfun (DECL_STRUCT_FUNCTION (node->decl)); + gcc_assert (cfun == NULL); dump_pass_list (all_lowering_passes, 1); dump_pass_list (all_small_ipa_passes, 1); dump_pass_list (all_regular_ipa_passes, 1); dump_pass_list (all_late_ipa_passes, 1); dump_pass_list (all_passes, 1); - - pop_cfun (); } diff --git a/gcc/store-motion.c b/gcc/store-motion.c index 530766f..6bc3680 100644 --- a/gcc/store-motion.c +++ b/gcc/store-motion.c @@ -1297,10 +1297,12 @@ public: bool pass_rtl_store_motion::gate (function *fun) { - return optimize > 0 && flag_gcse_sm - && !fun->calls_setjmp - && optimize_function_for_speed_p (fun) - && dbg_cnt (store_motion); + return (optimize > 0 + && flag_gcse_sm + && optimize_function_for_speed_p (fun) + && (fun == NULL + || (fun->calls_setjmp + && dbg_cnt (store_motion)))); } } // anon namespace diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c index 3fa2380..e7f8ee8 100644 --- a/gcc/tree-chkp-opt.c +++ b/gcc/tree-chkp-opt.c @@ -1337,11 +1337,13 @@ chkp_opt_execute (void) /* Pass gate. */ static bool -chkp_opt_gate (void) +chkp_opt_gate (function *fun) { - return chkp_function_instrumented_p (cfun->decl) - && (flag_chkp_optimize > 0 - || (flag_chkp_optimize == -1 && optimize > 0)); + return ((flag_chkp_optimize > 0 + || (flag_chkp_optimize == -1 + && optimize > 0)) + && (fun == NULL + || chkp_function_instrumented_p (fun->decl))); } namespace { @@ -1373,9 +1375,9 @@ public: return new pass_chkp_opt (m_ctxt); } - virtual bool gate (function *) + virtual bool gate (function *fun) { - return chkp_opt_gate (); + return chkp_opt_gate (fun); } virtual unsigned int execute (function *) diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index d2df4ba..6ab2b3e 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -4335,10 +4335,10 @@ chkp_execute (void) /* Instrumentation pass gate. */ static bool -chkp_gate (void) +chkp_gate (function *fun) { - return cgraph_node::get (cfun->decl)->instrumentation_clone - || lookup_attribute ("chkp ctor", DECL_ATTRIBUTES (cfun->decl)); + return cgraph_node::get (fun->decl)->instrumentation_clone + || lookup_attribute ("chkp ctor", DECL_ATTRIBUTES (fun->decl)); } namespace { @@ -4370,9 +4370,10 @@ public: return new pass_chkp (m_ctxt); } - virtual bool gate (function *) + virtual bool gate (function *fun) { - return chkp_gate (); + return (fun == NULL + || chkp_gate (fun)); } virtual unsigned int execute (function *) diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index c5b8688..2e07276 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -1754,7 +1754,8 @@ public: { /* With errors, normal optimization passes are not run. If we don't lower complex operations at all, rtl expansion will abort. */ - return !(fun->curr_properties & PROP_gimple_lcx); + return (fun == NULL + || !(fun->curr_properties & PROP_gimple_lcx)); } virtual unsigned int execute (function *) { return tree_lower_complex (); } diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index a111e9d93..38f6ebc 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -3751,7 +3751,11 @@ public: {} /* opt_pass methods: */ - virtual bool gate (function *fun) { return fun->eh->region_tree != NULL; } + virtual bool gate (function *fun) + { + return (fun == NULL + || fun->eh->region_tree != NULL); + } virtual unsigned int execute (function *); }; // class pass_lower_eh_dispatch @@ -4626,7 +4630,9 @@ public: opt_pass * clone () { return new pass_cleanup_eh (m_ctxt); } virtual bool gate (function *fun) { - return fun->eh != NULL && fun->eh->region_tree != NULL; + return (fun == NULL + || (fun->eh != NULL + && fun->eh->region_tree != NULL)); } virtual unsigned int execute (function *); diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 400ee01..7ca4086 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -2817,7 +2817,11 @@ public: bool pass_if_conversion::gate (function *fun) { - return (((flag_tree_loop_vectorize || fun->has_force_vectorize_loops) + bool do_vectorize = (flag_tree_loop_vectorize + || (fun == NULL + || fun->has_force_vectorize_loops)); + + return ((do_vectorize && flag_tree_loop_if_convert != 0) || flag_tree_loop_if_convert == 1 || flag_tree_loop_if_convert_stores == 1); diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 2589628..aac5ae0 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -2373,7 +2373,8 @@ public: virtual bool gate (function *fun) { /* Do nothing for funcions that was produced already in SSA form. */ - return !(fun->curr_properties & PROP_ssa); + return (fun == NULL + || !(fun->curr_properties & PROP_ssa)); } virtual unsigned int execute (function *); diff --git a/gcc/tree-ssa-loop.c b/gcc/tree-ssa-loop.c index ccb8f97..837c572 100644 --- a/gcc/tree-ssa-loop.c +++ b/gcc/tree-ssa-loop.c @@ -151,7 +151,11 @@ public: {} /* opt_pass methods: */ - virtual bool gate (function *fn) { return gate_loop (fn); } + virtual bool gate (function *fn) + { + return (fn == NULL + || gate_loop (fn)); + } }; // class pass_tree_loop @@ -188,7 +192,11 @@ public: {} /* opt_pass methods: */ - virtual bool gate (function *fn) { return !gate_loop (fn); } + virtual bool gate (function *fn) + { + return (fn == NULL + || !gate_loop (fn)); + } }; // class pass_tree_no_loop @@ -279,7 +287,9 @@ public: /* opt_pass methods: */ virtual bool gate (function *fun) { - return flag_tree_loop_vectorize || fun->has_force_vectorize_loops; + return (flag_tree_loop_vectorize + || (fun == NULL + || fun->has_force_vectorize_loops)); } virtual unsigned int execute (function *); diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 10d3314..716fcd4 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1118,7 +1118,8 @@ public: virtual bool gate (function *fun) { /* Do nothing for funcions that was produced already in SSA form. */ - return !(fun->curr_properties & PROP_ssa); + return (fun == NULL + || !(fun->curr_properties & PROP_ssa)); } virtual unsigned int execute (function *) diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index 0c70790..9503960 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -713,7 +713,8 @@ public: && !in_lto_p #endif /* This optimization is only for stdarg functions. */ - && fun->stdarg != 0); + && (fun == NULL + || fun->stdarg != 0)); } virtual unsigned int execute (function *); diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index dc11028..603b1d3 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -1754,7 +1754,8 @@ public: /* opt_pass methods: */ virtual bool gate (function *fun) { - return !(fun->curr_properties & PROP_gimple_lvec); + return (fun == NULL + || !(fun->curr_properties & PROP_gimple_lvec)); } virtual unsigned int execute (function *) -- 1.9.1