From patchwork Wed Mar 18 17:02:58 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: 451547 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 402ED140082 for ; Thu, 19 Mar 2015 04:03:22 +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=yenOa3Pw; 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=c0K1oCyy4h3YUmkSC flYMPyijhdWeuPq+QIqmGGMoU+zW/XoH5or91UOSGYgAAUprWNcX4y2njrjQXeaB B6gu6PGviPQ6fotb2fVk/GLCCOPX3WeyyO03aWOUBGVQ6qoZuTajTmYZllIL6olK FB0+BmVlF+uSwEt6aBA6bwRwyY= 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=qf/2+xTtww2eIV/DDnreCXq SVRA=; b=yenOa3Pw1l3O7+0OFUciSU+H2PInx9sH8LhsJiXWmvgW3TwWSbOFsin xTN6gsCFk8wxA7DAI2YGBoEdb6mzyl9IPKnKF9T3vZ4uaz8iDvNALObmGfQxHxsi qHIXNXDFNEN6PX05dRBG4U6iBb9aiXQ5xInfd/tazJoKOq7J/jVg= Received: (qmail 32036 invoked by alias); 18 Mar 2015 17:03: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 32015 invoked by uid 89); 18 Mar 2015 17:03:09 -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 17:03:07 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YYHN1-0003ml-1w from Tom_deVries@mentor.com ; Wed, 18 Mar 2015 10:03:03 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Wed, 18 Mar 2015 17:03:01 +0000 Message-ID: <5509AFC2.7000301@mentor.com> Date: Wed, 18 Mar 2015 18:02:58 +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> <55095B84.4070807@mentor.com> In-Reply-To: On 18-03-15 12:18, Richard Biener wrote: > On Wed, Mar 18, 2015 at 12:03 PM, Tom de Vries wrote: >> 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? > > Yeah - it makes the -fdump-passes "hack" more pervasive throughout > the compiler. > > I suppose it should instead build & push a "dummy" sturct function. > Like this? > Well, or simply don't care for it's brokeness. I'm afraid leaving it broken just means we'll keep coming back to it. So I'd prefer either fixing or removing. Thanks, - Tom Fix fdump-passes --- gcc/function.c | 37 ++++++++++++++++++++++++++++++++----- gcc/function.h | 2 ++ gcc/passes.c | 17 ++--------------- gcc/tree-chkp.c | 6 ++++-- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/gcc/function.c b/gcc/function.c index 2c3d142..9ddbad8 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4862,6 +4862,29 @@ prepare_function_start (void) frame_pointer_needed = 0; } +void +push_dummy_function (bool with_decl) +{ + tree fn_decl, fn_type, fn_result_decl; + + gcc_assert (!in_dummy_function); + in_dummy_function = true; + + if (with_decl) + { + fn_type = build_function_type_list (void_type_node, NULL_TREE); + fn_decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, NULL_TREE, + fn_type); + fn_result_decl = build_decl (UNKNOWN_LOCATION, RESULT_DECL, + NULL_TREE, void_type_node); + DECL_RESULT (fn_decl) = fn_result_decl; + } + else + fn_decl = NULL_TREE; + + push_struct_function (fn_decl); +} + /* Initialize the rtl expansion mechanism so that we can do simple things like generate sequences. This is used to provide a context during global initialization of some passes. You must call expand_dummy_function_end @@ -4870,9 +4893,7 @@ prepare_function_start (void) void init_dummy_function_start (void) { - gcc_assert (!in_dummy_function); - in_dummy_function = true; - push_struct_function (NULL_TREE); + push_dummy_function (false); prepare_function_start (); } @@ -5144,6 +5165,13 @@ expand_function_start (tree subr) stack_check_probe_note = emit_note (NOTE_INSN_DELETED); } +void +pop_dummy_function (void) +{ + pop_cfun (); + in_dummy_function = false; +} + /* Undo the effects of init_dummy_function_start. */ void expand_dummy_function_end (void) @@ -5159,8 +5187,7 @@ expand_dummy_function_end (void) free_after_parsing (cfun); free_after_compilation (cfun); - pop_cfun (); - in_dummy_function = false; + pop_dummy_function (); } /* Helper for diddle_return_value. */ diff --git a/gcc/function.h b/gcc/function.h index b89c5ae..349f80c 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -899,6 +899,8 @@ extern int get_next_funcdef_no (void); extern int get_last_funcdef_no (void); extern void allocate_struct_function (tree, bool); extern void push_struct_function (tree fndecl); +extern void push_dummy_function (bool); +extern void pop_dummy_function (void); extern void init_dummy_function_start (void); extern void init_function_start (tree); extern void stack_protect_epilogue (void); diff --git a/gcc/passes.c b/gcc/passes.c index 23a90d9..bca8dbb 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -944,32 +944,19 @@ dump_passes (void) void pass_manager::dump_passes () const { - struct cgraph_node *n, *node = NULL; + push_dummy_function (true); 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)); - 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 (); + pop_dummy_function (); } - /* Returns the pass with NAME. */ static opt_pass * diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index d2df4ba..16afadf 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -4337,8 +4337,10 @@ chkp_execute (void) static bool chkp_gate (void) { - return cgraph_node::get (cfun->decl)->instrumentation_clone - || lookup_attribute ("chkp ctor", DECL_ATTRIBUTES (cfun->decl)); + cgraph_node *node = cgraph_node::get (cfun->decl); + return ((node != NULL + && node->instrumentation_clone) + || lookup_attribute ("chkp ctor", DECL_ATTRIBUTES (cfun->decl))); } namespace { -- 1.9.1