From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64326 invoked by alias); 14 Mar 2016 15:33:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 64267 invoked by uid 89); 14 Mar 2016 15:33:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:functio, H*Ad:D*cz, atm 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 14 Mar 2016 15:32:40 +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 1afUTy-0006Ze-Kd from Tom_deVries@mentor.com ; Mon, 14 Mar 2016 08:32:35 -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; Mon, 14 Mar 2016 15:32:33 +0000 To: Richard Biener From: Tom de Vries Subject: [PATCH, PR70161] Fix fdump-ipa-all-graph CC: GCC Patches , Jan Hubicka Message-ID: <56E6D97F.3030606@mentor.com> Date: Mon, 14 Mar 2016 15:33:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000503070101090805080604" X-SW-Source: 2016-03/txt/msg00776.txt.bz2 --------------000503070101090805080604 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1020 Hi, this patch fixes PR70161, a 4.9/5/6 regression. Currently when using -fdump-ipa-all-graph, the compiler ICEs in execute_function_dump when testing for pass->graph_dump_initialized, because pass == NULL. The patch fixes: - the ICE by setting the pass argument in the call to execute_function_dump in execute_one_ipa_transform_pass - a subsequent ICE (triggered with -fipa-pta) by saving, resetting and restoring dump_file_name in cgraph_node::get_body, alongside the saving and restoring of the dump_file variable. - the duplicate edges in the subsequently generated dot file by ensuring that execute_function_dump is called only once per function per pass. [ Note that this bit also has an effect for the normal dump files for the ipa passes with transform function. For those functions, atm execute_function_dump is called both after execute and after transform. With the patch, it's only called after transform. ] Bootstrapped and reg-tested on x86_64. OK for stage4? Thanks, - Tom --------------000503070101090805080604 Content-Type: text/x-patch; name="0002-Fix-fdump-ipa-all-graph.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0002-Fix-fdump-ipa-all-graph.patch" Content-length: 2449 Fix fdump-ipa-all-graph 2016-03-14 Tom de Vries PR ipa/70161 * cgraph.c (cgraph_node::get_body): Save, reset and restore dump_file_name. * passes.c (execute_one_ipa_transform_pass): Add missing argument to execute_function_dump. (execute_one_pass): Don't dump function if it will be dumped after ipa transform. --- gcc/cgraph.c | 3 +++ gcc/passes.c | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 7727313..f187913 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -3365,7 +3365,9 @@ cgraph_node::get_body (void) { opt_pass *saved_current_pass = current_pass; FILE *saved_dump_file = dump_file; + const char *saved_dump_file_name = dump_file_name; int saved_dump_flags = dump_flags; + dump_file_name = NULL; push_cfun (DECL_STRUCT_FUNCTION (decl)); execute_all_ipa_transforms (); @@ -3377,6 +3379,7 @@ cgraph_node::get_body (void) current_pass = saved_current_pass; dump_file = saved_dump_file; + dump_file_name = saved_dump_file_name; dump_flags = saved_dump_flags; } return updated; diff --git a/gcc/passes.c b/gcc/passes.c index bbe35b3..5aa2b32 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -2219,7 +2219,7 @@ execute_one_ipa_transform_pass (struct cgraph_node *node, check_profile_consistency (pass->static_pass_number, 1, true); if (dump_file) - do_per_function (execute_function_dump, NULL); + do_per_function (execute_function_dump, pass); pass_fini_dump_file (pass); current_pass = NULL; @@ -2356,15 +2356,15 @@ execute_one_pass (opt_pass *pass) check_profile_consistency (pass->static_pass_number, 1, true); verify_interpass_invariants (); - if (dump_file) - do_per_function (execute_function_dump, pass); - if (pass->type == IPA_PASS) + if (pass->type == IPA_PASS + && ((ipa_opt_pass_d *)pass)->function_transform) { struct cgraph_node *node; - if (((ipa_opt_pass_d *)pass)->function_transform) - FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) - node->ipa_transforms_to_apply.safe_push ((ipa_opt_pass_d *)pass); + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) + node->ipa_transforms_to_apply.safe_push ((ipa_opt_pass_d *)pass); } + else if (dump_file) + do_per_function (execute_function_dump, pass); if (!current_function_decl) symtab->process_new_functions (); --------------000503070101090805080604--