From patchwork Thu May 21 15:36:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 475069 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 3F5DA14027F for ; Fri, 22 May 2015 01:37:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=WhI09jL/; 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:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=FHW4fSDspR32KXzI zPZS6tBG6sDYmCJXy/ugIZJ77DNvG6yTfa8edZIPbG8E2xIO26rSzzpHOOD4Mea5 2fv0hV7tMmuIbV3z5GHctgYyS7a6kiG5cGGCVP221VoPiaVewFF74vCafVBBYa0o oncjsc2m7sahRIt+l78+TSKdaPE= 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:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=HDqcvLEYFkT70II44Svd6t ocV60=; b=WhI09jL/y7XSlPQcbyUIxx2O6WL2uozbNPJpTLm46IGCoQQH0Gg2Vp X0H5/7egfEowujaGM0X97Vzee62xDqPb5zgubuLt3JxAqbWbqR64da1pp9oSmAjn oy2PV+FfhKs8xnrTM6wIuvpl+pU4rGaLxe7YMBGDj1YHOObuK+CWw= Received: (qmail 95157 invoked by alias); 21 May 2015 15:36:55 -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 95147 invoked by uid 89); 21 May 2015 15:36:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_05, 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; Thu, 21 May 2015 15:36:46 +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 1YvSWX-0003Mc-48 from Thomas_Schwinge@mentor.com ; Thu, 21 May 2015 08:36:41 -0700 Received: from feldtkeller.schwinge.homeip.net (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; Thu, 21 May 2015 16:36:39 +0100 From: Thomas Schwinge To: Tom de Vries , Jan Hubicka CC: "gcc-patches@gcc.gnu.org" , Jakub Jelinek , Julian Brown Subject: Re: Don't dump low gimple functions in gimple dump In-Reply-To: <537B0F6D.7060808@mentor.com> References: <537B0F6D.7060808@mentor.com> <87k3bnecq3.fsf@schwinge.name> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu) Date: Thu, 21 May 2015 17:36:36 +0200 Message-ID: <87617mndrv.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! It's just been a year. ;-P In early March, I (hopefully correctly) adapted Tom's patch to apply to then-current GCC trunk sources; posting this here. Is the general approach OK? On Tue, 20 May 2014 10:16:45 +0200, Tom de Vries wrote: > Honza, > > Consider this program: > ... > int > main(void) > { > #pragma omp parallel > { > extern void foo(void); > foo (); > } > return 0; > } > ... > > When compiling this program with -fopenmp, the ompexp pass splits off a new > function called main._omp_fn.0 containing the call to foo. The new function is > then dumped into the gimple dump by analyze_function. > > There are two problems with this: > - the new function is in low gimple, and is dumped next to high gimple > functions > - since it's already low, the new function is not lowered, and 'goes missing' > in the dumps following the gimple dump, until it reappears again after the > last lowering dump. > [ http://gcc.gnu.org/ml/gcc/2014-03/msg00312.html ] > > This patch fixes the problems by ensuring that analyze_function only dumps the > new function to the gimple dump after gimplification (specifically, by moving > the dump_function call into gimplify_function_tree. That makes the call to > dump_function in finalize_size_functions superfluous). > > That also requires us to add a call to dump_function in finalize_task_copyfn, > where we split off a new high gimple function. > > And in expand_omp_taskreg and expand_omp_target, where we split off a new low > gimple function, we now dump the new function into the current (ompexp) dump > file, which is the last lowering dump. > > Finally, we dump an information statement at the start of > cgraph_add_new_function to give a better idea when and what kind of function is > created. > > Bootstrapped and reg-tested on x86_64. > > OK for trunk ? > > Thanks, > - Tom commit b925b393c3d975a9281789d97aff8a91a8b53be0 Author: Thomas Schwinge Date: Sun Mar 1 15:05:15 2015 +0100 Don't dump low gimple functions in gimple dump id:"537B0F6D.7060808@mentor.com" or id:"53734DC5.90001@mentor.com" 2014-05-19 Tom de Vries * cgraphunit.c (cgraph_add_new_function): Dump message on new function. (analyze_function): Don't dump function to gimple dump file. * gimplify.c: Add tree-dump.h include. (gimplify_function_tree): Dump function to gimple dump file. * omp-low.c: Add tree-dump.h include. (finalize_task_copyfn): Dump new function to gimple dump file. (expand_omp_taskreg, expand_omp_target): Dump new function to dump file. * stor-layout.c (finalize_size_functions): Don't dump function to gimple dump file. * gcc.dg/gomp/dump-task.c: New test. --- gcc/cgraphunit.c | 15 ++++++++++++++- gcc/gimplify.c | 3 +++ gcc/omp-low.c | 6 ++++++ gcc/stor-layout.c | 1 - gcc/testsuite/gcc.dg/gomp/dump-task.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) Grüße, Thomas diff --git gcc/cgraphunit.c gcc/cgraphunit.c index 8280fc4..0860c86 100644 --- gcc/cgraphunit.c +++ gcc/cgraphunit.c @@ -501,6 +501,20 @@ cgraph_node::add_new_function (tree fndecl, bool lowered) { gcc::pass_manager *passes = g->get_passes (); cgraph_node *node; + + if (dump_file) + { + const char *function_type = ((gimple_has_body_p (fndecl)) + ? (lowered + ? "low gimple" + : "high gimple") + : "to-be-gimplified"); + fprintf (dump_file, + "Added new %s function %s to callgraph\n", + function_type, + fndecl_name (fndecl)); + } + switch (symtab->state) { case PARSING: @@ -629,7 +643,6 @@ cgraph_node::analyze (void) body. */ if (!gimple_has_body_p (decl)) gimplify_function_tree (decl); - dump_function (TDI_generic, decl); /* Lower the function. */ if (!lowered) diff --git gcc/gimplify.c gcc/gimplify.c index 9214648..d6c500d 100644 --- gcc/gimplify.c +++ gcc/gimplify.c @@ -87,6 +87,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-low.h" #include "cilk.h" #include "gomp-constants.h" +#include "tree-dump.h" #include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name */ #include "tree-pass.h" /* FIXME: only for PROP_gimple_any */ @@ -9435,6 +9436,8 @@ gimplify_function_tree (tree fndecl) cfun->curr_properties = PROP_gimple_any; pop_cfun (); + + dump_function (TDI_generic, fndecl); } /* Return a dummy expression of type TYPE in order to keep going after an diff --git gcc/omp-low.c gcc/omp-low.c index fac32b3..2839d8f 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -109,6 +109,7 @@ along with GCC; see the file COPYING3. If not see #include "lto-section-names.h" #include "gomp-constants.h" #include "gimple-pretty-print.h" +#include "tree-dump.h" /* Lowering of OMP parallel and workshare constructs proceeds in two @@ -1714,6 +1715,7 @@ finalize_task_copyfn (gomp_task *task_stmt) pop_cfun (); /* Inform the callgraph about the new function. */ + dump_function (TDI_generic, child_fn); cgraph_node::add_new_function (child_fn, false); } @@ -6073,6 +6075,8 @@ expand_omp_taskreg (struct omp_region *region) /* Inform the callgraph about the new function. */ DECL_STRUCT_FUNCTION (child_fn)->curr_properties = cfun->curr_properties; cgraph_node::add_new_function (child_fn, true); + if (dump_file) + dump_function_to_file (child_fn, dump_file, dump_flags); /* Fix the callgraph edges for child_cfun. Those for cfun will be fixed in a following pass. */ @@ -9527,6 +9531,8 @@ expand_omp_target (struct omp_region *region) /* Inform the callgraph about the new function. */ DECL_STRUCT_FUNCTION (child_fn)->curr_properties = cfun->curr_properties; cgraph_node::add_new_function (child_fn, true); + if (dump_file) + dump_function_to_file (child_fn, dump_file, dump_flags); #ifdef ENABLE_OFFLOADING /* Add the new function to the offload table. */ diff --git gcc/stor-layout.c gcc/stor-layout.c index 273a12b..b3f9852 100644 --- gcc/stor-layout.c +++ gcc/stor-layout.c @@ -318,7 +318,6 @@ finalize_size_functions (void) set_cfun (NULL); dump_function (TDI_original, fndecl); gimplify_function_tree (fndecl); - dump_function (TDI_generic, fndecl); cgraph_node::finalize_function (fndecl, false); } diff --git gcc/testsuite/gcc.dg/gomp/dump-task.c gcc/testsuite/gcc.dg/gomp/dump-task.c new file mode 100644 index 0000000..08ae5c3 --- /dev/null +++ gcc/testsuite/gcc.dg/gomp/dump-task.c @@ -0,0 +1,33 @@ +/* https://gcc.gnu.org/ml/gcc/2014-03/msg00312.html + https://gcc.gnu.org/ml/gcc/2014-05/msg00117.html */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp -fdump-tree-gimple -fdump-tree-ompexp" } */ + +int +main(void) +{ +#pragma omp parallel + { + extern void foo(void); + foo (); + } + return 0; +} + + +/* Check that low gimple representation does not end up in high gimple + dump. */ +/* { dg-final { scan-tree-dump-not "main._omp_fn.0" "gimple" } } */ + +/* Check for 3 references in ompexp dump: new function notification, function + dump and reference in main. */ +/* { dg-final { scan-tree-dump-times "main._omp_fn.0" 3 "ompexp" } } */ + +/* Check for function dump of main._omp_fn.0. */ +/* { dg-final { scan-tree-dump-times "main._omp_fn.0 \\(void" 1 "ompexp" } } */ + +/* Check for presence of function body of main._omp_fn.0. */ +/* { dg-final { scan-tree-dump-times "foo \\(\\)" 1 "ompexp" } } */ + +/* { dg-final { cleanup-tree-dump "gimple" } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */