Re: Don't dump low gimple functions in gimple dump

2015-10-22 Thread Tom de Vries

On 22/10/15 14:27, Jakub Jelinek wrote:

The state before the patch is:
1) the omp_fn children created during the pre-SSA ompexp pass are dumped
first in the *.ssa dump and in all the following ones (these are created
as low gimple, non-SSA)


Hi,

I do see those child fns before the ssa dump, in the fixup_cfg1 dump 
(and with -fipa-tree-all, also in the visibility dump, just after the 
ompexp dump).


[ Not that I disagree with dumping the child fn in ompexp dump. ]


2) the omp_cpyfn children created during the pre-SSA ompexp pass are dumped
first in the *.omplower dump and in all the following ones (these are
created as high gimple)
3) the omp_fn children created during the parloops/ompexpssa passes
are dumped first post-IPA (or during IPA?) and in all the following ones
(these are created as SSA gimple)




3) is fine


Not fine for me though.

As I wrote earlier ( 
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01316.html ):

...
The problems I'm trying to solve with this patch are the following:
- even if you're compiling a single function, part of the function
  occurs twice (once in the original, once in the split-off
  function), making formulating scan-tree-dumps more complicated for
  parloops.
- the intuitive thing is to look in the parloops tree-dump and look at
  the original function and the split-off function, and think that the
  split-off function is the immediate result of the split-off that
  happened in the pass, which is incorrect (since it jumps back in the
  pass list and traverses other passes before arriving back at
  parloops).

Adding something like a flag -fno-dump-new-function would solve the 
first problem, but not the second.


We could also dump new functions in a different dump file 
src.c.new.123t.pass, and this would solve both problems. But it will 
cause the 'where did that function go' confusion, certainly initially.

...

Thanks,
- Tom



Re: Don't dump low gimple functions in gimple dump

2015-10-22 Thread Jakub Jelinek
On Thu, Jun 04, 2015 at 05:02:42PM +0200, Tom de Vries wrote:
> >So why does add_new_function not do the dumping and to the correct
> >place?  That is,
> >you are dumping things twice here, once in omp expansion and then again when 
> >the
> >new function reaches omp expansion?
> >
> 
> Dumping twice doesn't happen for omp-annotated source code. But indeed,
> dumping twice does happen in ompexpssa for the parloops/ompexpssa case with
> this patch, which is confusing.  And even if we would eliminate the dumping
> when the new function reaches omp expansion, still it would be confusing
> because the dump of the function would not be the version inbetween the
> preceding and succeeding dump.

I've committed following patch to gomp-4_5-branch for this.

The state before the patch is:
1) the omp_fn children created during the pre-SSA ompexp pass are dumped
   first in the *.ssa dump and in all the following ones (these are created
   as low gimple, non-SSA)
2) the omp_cpyfn children created during the pre-SSA ompexp pass are dumped
   first in the *.omplower dump and in all the following ones (these are
   created as high gimple)
3) the omp_fn children created during the parloops/ompexpssa passes
   are dumped first post-IPA (or during IPA?) and in all the following ones
   (these are created as SSA gimple)

2) and 3) is fine, on 1) I don't like the fact that one can see the child
functions only in the SSA form, not before it.  Thus, following patch
arranges for only the 1) case to change, those functions are dumped now
into the *.ompexp dump.  As e.g. for C++ sometimes the dumped function name
is not too descriptive (e.g. ), I've hacked things up so that also
the
;; Function
headers are dumped including the assembler name, and because there can be
many child functions emitted for a single original function, I chose to
dump again the
;; Function
header for the original function if any child functions were dumped.
The original function will have then two headers in the dump file, but I
think it is more readable that way.

2015-10-22  Jakub Jelinek  

* omp-low.c: Include tree-pretty-print.h.
(omp_any_child_fn_dumped): New variable.
(expand_omp_taskreg, expand_omp_target): Call
assign_assembler_name_if_neeeded on child_fn if current_function_decl
has assembler name set, but child_fn does not.  Dump the header
and IL of the child function when not in SSA form.
(expand_omp): Clear omp_any_child_fn_dumped.  Dump function header
again if we have dumped any child functions.

--- gcc/omp-low.c.jj2015-10-22 13:41:23.279881315 +0200
+++ gcc/omp-low.c   2015-10-22 14:11:23.488003543 +0200
@@ -81,6 +81,7 @@ along with GCC; see the file COPYING3.
 #include "context.h"
 #include "lto-section-names.h"
 #include "gomp-constants.h"
+#include "tree-pretty-print.h"
 
 /* Lowering of OMP parallel and workshare constructs proceeds in two
phases.  The first phase scans the function looking for OMP statements
@@ -244,6 +245,7 @@ static int target_nesting_level;
 static struct omp_region *root_omp_region;
 static bitmap task_shared_vars;
 static vec taskreg_contexts;
+static bool omp_any_child_fn_dumped;
 
 static void scan_omp (gimple_seq *, omp_context *);
 static tree scan_omp_1_op (tree *, int *, void *);
@@ -6739,9 +6741,15 @@ expand_omp_taskreg (struct omp_region *r
   node->parallelized_function = 1;
   cgraph_node::add_new_function (child_fn, true);
 
+  bool need_asm = DECL_ASSEMBLER_NAME_SET_P (current_function_decl)
+ && !DECL_ASSEMBLER_NAME_SET_P (child_fn);
+
   /* Fix the callgraph edges for child_cfun.  Those for cfun will be
 fixed in a following pass.  */
   push_cfun (child_cfun);
+  if (need_asm)
+   assign_assembler_name_if_neeeded (child_fn);
+
   if (optimize)
optimize_omp_library_calls (entry_stmt);
   cgraph_edge::rebuild_edges ();
@@ -6767,6 +6775,13 @@ expand_omp_taskreg (struct omp_region *r
verify_loop_structure ();
 #endif
   pop_cfun ();
+
+  if (dump_file && !gimple_in_ssa_p (cfun))
+   {
+ omp_any_child_fn_dumped = true;
+ dump_function_header (dump_file, child_fn, dump_flags);
+ dump_function_to_file (child_fn, dump_file, dump_flags);
+   }
 }
 
   /* Emit a library call to launch the children threads.  */
@@ -11575,9 +11590,14 @@ expand_omp_target (struct omp_region *re
   vec_safe_push (offload_funcs, child_fn);
 #endif
 
+  bool need_asm = DECL_ASSEMBLER_NAME_SET_P (current_function_decl)
+ && !DECL_ASSEMBLER_NAME_SET_P (child_fn);
+
   /* Fix the callgraph edges for child_cfun.  Those for cfun will be
 fixed in a following pass.  */
   push_cfun (child_cfun);
+  if (need_asm)
+   assign_assembler_name_if_neeeded (child_fn);
   cgraph_edge::rebuild_edges ();
 
 #ifdef ENABLE_OFFLOADING
@@ -11605,6 +11625,13 @@ expand_omp_target 

Re: Don't dump low gimple functions in gimple dump

2015-10-22 Thread Jakub Jelinek
On Thu, Oct 22, 2015 at 02:51:34PM +0200, Tom de Vries wrote:
> On 22/10/15 14:27, Jakub Jelinek wrote:
> >The state before the patch is:
> >1) the omp_fn children created during the pre-SSA ompexp pass are dumped
> >first in the *.ssa dump and in all the following ones (these are created
> >as low gimple, non-SSA)
> 
> Hi,
> 
> I do see those child fns before the ssa dump, in the fixup_cfg1 dump (and
> with -fipa-tree-all, also in the visibility dump, just after the ompexp
> dump).

Oh, indeed.  Any case, I think, with the patch 1) behaves the most desirable
way now, no dumps before ompexp show it, and ompexp dump shows both the new
child functions and original function with the outlined code already
removed.  And all dumps after ompexp show both as well.

> [ Not that I disagree with dumping the child fn in ompexp dump. ]
> 
> >2) the omp_cpyfn children created during the pre-SSA ompexp pass are dumped
> >first in the *.omplower dump and in all the following ones (these are
> >created as high gimple)

And this is probably fine too, as the cpyfn functions are artificially
created, they don't contain code that has been moved from somewhere else.

> >3) the omp_fn children created during the parloops/ompexpssa passes
> >are dumped first post-IPA (or during IPA?) and in all the following ones
> >(these are created as SSA gimple)

Bet what you'd want most would be to be able to create new functions and
mark them not just as SSA low gimple, but also be able to say, skip
everything in the pass pipeline for these functions until pass this and
this, i.e. start pass pipeline with pass->next of the creating pass.
Then it would neither show up in the earlier dumps, nor be processed
multiple times by the same passes.  We'd need the && !gimple_in_ssa_p
I've added in the patch removed once that is done...

Jakub


Re: Don't dump low gimple functions in gimple dump

2015-06-08 Thread Richard Biener
On Thu, Jun 4, 2015 at 5:02 PM, Tom de Vries tom_devr...@mentor.com wrote:
 On 22/05/15 11:27, Richard Biener wrote:

 On Thu, May 21, 2015 at 5:36 PM, Thomas Schwinge
 tho...@codesourcery.com wrote:

 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 tom_devr...@mentor.com
 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 tho...@codesourcery.com
 Date:   Sun Mar 1 15:05:15 2015 +0100

  Don't dump low gimple functions in gimple dump

  id:537b0f6d.7060...@mentor.com or id:53734dc5.90...@mentor.com

  2014-05-19  Tom de Vries  t...@codesourcery.com

  * 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(-)

 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:


 Split off this hunk as a seperate patch:
 https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00416.html .


 @@ -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 @@ 

Re: Don't dump low gimple functions in gimple dump

2015-06-04 Thread Tom de Vries

On 22/05/15 11:27, Richard Biener wrote:

On Thu, May 21, 2015 at 5:36 PM, Thomas Schwinge
tho...@codesourcery.com wrote:

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 tom_devr...@mentor.com 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 tho...@codesourcery.com
Date:   Sun Mar 1 15:05:15 2015 +0100

 Don't dump low gimple functions in gimple dump

 id:537b0f6d.7060...@mentor.com or id:53734dc5.90...@mentor.com

 2014-05-19  Tom de Vries  t...@codesourcery.com

 * 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(-)

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:


Split off this hunk as a seperate patch: 
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00416.html .



@@ -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);


Err - that dumps gimple now.  I think the dump you removed above was

Re: Don't dump low gimple functions in gimple dump

2015-05-22 Thread Richard Biener
On Thu, May 21, 2015 at 5:36 PM, Thomas Schwinge
tho...@codesourcery.com wrote:
 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 tom_devr...@mentor.com 
 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 tho...@codesourcery.com
 Date:   Sun Mar 1 15:05:15 2015 +0100

 Don't dump low gimple functions in gimple dump

 id:537b0f6d.7060...@mentor.com or id:53734dc5.90...@mentor.com

 2014-05-19  Tom de Vries  t...@codesourcery.com

 * 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(-)

 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);

Err - that dumps gimple now.  I think the dump you removed above was
simply bogus
and should have used TDI_gimple?  Or is TDI_generic just 

Re: Don't dump low gimple functions in gimple dump

2015-05-21 Thread Thomas Schwinge
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 tom_devr...@mentor.com 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 tho...@codesourcery.com
Date:   Sun Mar 1 15:05:15 2015 +0100

Don't dump low gimple functions in gimple dump

id:537b0f6d.7060...@mentor.com or id:53734dc5.90...@mentor.com

2014-05-19  Tom de Vries  t...@codesourcery.com

* 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(-)

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