From 66460ec1ca00302fa8c2e2b4dbca1e9ea807ac9f Mon Sep 17 00:00:00 2001 From: vries Date: Sat, 21 Mar 2015 10:14:10 +0000 Subject: [PATCH] Mark omp thread functions as parallelized 2015-03-21 Tom de Vries 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, finalize_task_copyfn): 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. * Makefile.in (GTFILES): Remove tree-parloops.c git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221551 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 17 +++++++++++++++++ gcc/Makefile.in | 1 - gcc/cgraph.c | 2 ++ gcc/cgraph.h | 2 ++ gcc/lto-cgraph.c | 2 ++ gcc/omp-low.c | 2 ++ gcc/tree-parloops.c | 27 ++++++++------------------- 7 files changed, 33 insertions(+), 20 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e15dfc8..c9737fa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2015-03-21 Tom de Vries + + 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, finalize_task_copyfn): 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. + * Makefile.in (GTFILES): Remove tree-parloops.c + 2015-03-20 Vladimir Makarov PR rtl-optimization/64366 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index de1f3b6..8af45a6 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2321,7 +2321,6 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h $(srcdir)/coretypes.h \ $(srcdir)/tree-scalar-evolution.c \ $(srcdir)/tree-ssa-operands.h \ $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \ - $(srcdir)/tree-parloops.c \ $(srcdir)/omp-low.c \ $(srcdir)/omp-low.h \ $(srcdir)/targhooks.c $(out_file) $(srcdir)/passes.c $(srcdir)/cgraphunit.c \ diff --git a/gcc/cgraph.c b/gcc/cgraph.c index e2958c4..35164f9 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -2008,6 +2008,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..80bddf0 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1564,6 +1564,7 @@ finalize_task_copyfn (gomp_task *task_stmt) /* Inform the callgraph about the new function. */ cgraph_node::add_new_function (child_fn, false); + cgraph_node::get (child_fn)->parallelized_function = 1; } /* Destroy a omp_context data structures. Called through the splay tree @@ -5569,6 +5570,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; /* Fix the callgraph edges for child_cfun. Those for cfun will be fixed in a following pass. */ diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index a584460..62a6444 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -75,6 +75,9 @@ along with GCC; see the file COPYING3. If not see #include "tree-parloops.h" #include "omp-low.h" #include "tree-nested.h" +#include "plugin-api.h" +#include "ipa-ref.h" +#include "cgraph.h" /* This pass tries to distribute iterations of loops into several threads. The implementation is straightforward -- for each loop we test whether its @@ -1422,21 +1425,14 @@ separate_decls_in_region (edge entry, edge exit, } } -/* Bitmap containing uids of functions created by parallelization. We cannot - allocate it from the default obstack, as it must live across compilation - of several functions; we make it gc allocated instead. */ - -static GTY(()) bitmap parallelized_functions; - -/* Returns true if FN was created by create_loop_fn. */ +/* Returns true if FN was created to run in parallel. */ bool -parallelized_function_p (tree fn) +parallelized_function_p (tree fndecl) { - if (!parallelized_functions || !DECL_ARTIFICIAL (fn)) - return false; - - return bitmap_bit_p (parallelized_functions, DECL_UID (fn)); + cgraph_node *node = cgraph_node::get (fndecl); + gcc_assert (node != NULL); + return node->parallelized_function; } /* Creates and returns an empty function that will receive the body of @@ -1459,10 +1455,6 @@ create_loop_fn (location_t loc) type = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); decl = build_decl (loc, FUNCTION_DECL, name, type); - if (!parallelized_functions) - parallelized_functions = BITMAP_GGC_ALLOC (); - bitmap_set_bit (parallelized_functions, DECL_UID (decl)); - TREE_STATIC (decl) = 1; TREE_USED (decl) = 1; DECL_ARTIFICIAL (decl) = 1; @@ -2314,6 +2306,3 @@ make_pass_parallelize_loops (gcc::context *ctxt) { return new pass_parallelize_loops (ctxt); } - - -#include "gt-tree-parloops.h" -- 2.7.4