On Fri, Mar 20, 2015 at 12:37:11PM +0100, Tom de Vries wrote:
> Mark omp thread functions as parallelized
> 
> 2015-03-20  Tom de Vries  <t...@codesourcery.com>
> 
>       PR tree-optimization/65458
>       * cgraph.c (cgraph_node::dump): Handle parallelized_function field.
>       * cgraph.h (cgraph_node): Add parallelized_function field.
>       * lto-cgraph.c (lto_output_node): Write parallelized_function field.
>       (input_overwrite_node): Read parallelized_function field.
>       * omp-low.c (expand_omp_taskreg):  Set parallelized_function on
>       cgraph_node for child_fn.
>       * tree-parloops.c: Add include of plugin-api.h, ipa-ref.h and cgraph.h.
>       Remove include of gt-tree-parloops.h.
>       (parallelized_functions): Remove static variable.
>       (parallelized_function_p): Rewrite using parallelized_function field of
>       cgraph_node.
>       (create_loop_fn): Remove adding to parallelized_functions.

You should also remove tree-parloops.c from GTFILES in gcc/Makefile.in.

> ---
>  gcc/cgraph.c        |  2 ++
>  gcc/cgraph.h        |  2 ++
>  gcc/lto-cgraph.c    |  2 ++
>  gcc/omp-low.c       |  1 +
>  gcc/tree-parloops.c | 27 ++++++++-------------------
>  5 files changed, 15 insertions(+), 19 deletions(-)
> 
> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index ede58bf..4573057 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -2009,6 +2009,8 @@ cgraph_node::dump (FILE *f)
>      fprintf (f, " only_called_at_exit");
>    if (opt_for_fn (decl, optimize_size))
>      fprintf (f, " optimize_size");
> +  if (parallelized_function)
> +    fprintf (f, " parallelized_function");
>  
>    fprintf (f, "\n");
>  
> diff --git a/gcc/cgraph.h b/gcc/cgraph.h
> index 52b15c5..650e689 100644
> --- a/gcc/cgraph.h
> +++ b/gcc/cgraph.h
> @@ -1317,6 +1317,8 @@ public:
>    unsigned nonfreeing_fn : 1;
>    /* True if there was multiple COMDAT bodies merged by lto-symtab.  */
>    unsigned merged : 1;
> +  /* True if function was created to be executed in parallel.  */
> +  unsigned parallelized_function : 1;
>  
>  private:
>    /* Worker for call_for_symbol_and_aliases.  */
> diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
> index c875fed..088de86 100644
> --- a/gcc/lto-cgraph.c
> +++ b/gcc/lto-cgraph.c
> @@ -574,6 +574,7 @@ lto_output_node (struct lto_simple_output_block *ob, 
> struct cgraph_node *node,
>    bp_pack_value (&bp, node->icf_merged, 1);
>    bp_pack_value (&bp, node->nonfreeing_fn, 1);
>    bp_pack_value (&bp, node->thunk.thunk_p, 1);
> +  bp_pack_value (&bp, node->parallelized_function, 1);
>    bp_pack_enum (&bp, ld_plugin_symbol_resolution,
>               LDPR_NUM_KNOWN, node->resolution);
>    bp_pack_value (&bp, node->instrumentation_clone, 1);
> @@ -1209,6 +1210,7 @@ input_overwrite_node (struct lto_file_decl_data 
> *file_data,
>    node->icf_merged = bp_unpack_value (bp, 1);
>    node->nonfreeing_fn = bp_unpack_value (bp, 1);
>    node->thunk.thunk_p = bp_unpack_value (bp, 1);
> +  node->parallelized_function = bp_unpack_value (bp, 1);
>    node->resolution = bp_unpack_enum (bp, ld_plugin_symbol_resolution,
>                                    LDPR_NUM_KNOWN);
>    node->instrumentation_clone = bp_unpack_value (bp, 1);
> diff --git a/gcc/omp-low.c b/gcc/omp-low.c
> index 48d73cb..5ca9e84 100644
> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -5569,6 +5569,7 @@ 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);
> +      cgraph_node::get (child_fn)->parallelized_function = 1;

IMHO you want to do this in create_omp_child_function instead, that way you
handle it not just for the parallel region, but also e.g. for the task copy
functions etc.

Ok with those changes.

        Jakub

Reply via email to