Run pass_ipa_pta before pass_local_optimization_passes
---
gcc/gimple-ssa.h | 2 ++
gcc/passes.def | 1 +
gcc/tree-pass.h | 1 +
gcc/tree-ssa-structalias.c | 60 +++++++++++++++++++++++++++++++++++++++++++---
4 files changed, 61 insertions(+), 3 deletions(-)
@@ -83,6 +83,8 @@ struct GTY(()) gimple_df {
/* The PTA solution for the ESCAPED artificial variable. */
struct pt_solution escaped;
+ bool clique_base_annotation_done;
+
/* A map of decls to artificial ssa-names that point to the partition
of the decl. */
hash_map<tree, tree> * GTY((skip(""))) decls_to_pointers;
@@ -68,6 +68,7 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_rebuild_cgraph_edges);
POP_INSERT_PASSES ()
+ NEXT_PASS (pass_ipa_pta_oacc_kernels);
NEXT_PASS (pass_local_optimization_passes);
PUSH_INSERT_PASSES_WITHIN (pass_local_optimization_passes)
NEXT_PASS (pass_fixup_cfg);
@@ -497,6 +497,7 @@ extern ipa_opt_pass_d *make_pass_ipa_devirt (gcc::context *ctxt);
extern ipa_opt_pass_d *make_pass_ipa_reference (gcc::context *ctxt);
extern ipa_opt_pass_d *make_pass_ipa_pure_const (gcc::context *ctxt);
extern simple_ipa_opt_pass *make_pass_ipa_pta (gcc::context *ctxt);
+extern simple_ipa_opt_pass *make_pass_ipa_pta_oacc_kernels (gcc::context *ctxt);
extern simple_ipa_opt_pass *make_pass_ipa_tm (gcc::context *ctxt);
extern simple_ipa_opt_pass *make_pass_target_clone (gcc::context *ctxt);
extern simple_ipa_opt_pass *make_pass_dispatcher_calls (gcc::context *ctxt);
@@ -6939,7 +6939,7 @@ solve_constraints (void)
at the start of the file for an algorithmic overview. */
static void
-compute_points_to_sets (void)
+compute_points_to_sets (bool set_points_to_info)
{
basic_block bb;
unsigned i;
@@ -6981,6 +6981,9 @@ compute_points_to_sets (void)
/* From the constraints compute the points-to sets. */
solve_constraints ();
+ if (!set_points_to_info)
+ goto done;
+
/* Compute the points-to set for ESCAPED used for call-clobber analysis. */
cfun->gimple_df->escaped = find_what_var_points_to (cfun->decl,
get_varinfo (escaped_id));
@@ -7057,6 +7060,7 @@ compute_points_to_sets (void)
}
}
+ done:
timevar_pop (TV_TREE_PTA);
}
@@ -7289,6 +7293,8 @@ compute_dependence_clique (void)
unsigned int
compute_may_aliases (void)
{
+ bool set_points_to_info = true;
+
if (cfun->gimple_df->ipa_pta)
{
if (dump_file)
@@ -7300,13 +7306,16 @@ compute_may_aliases (void)
dump_alias_info (dump_file);
}
- return 0;
+ if (cfun->gimple_df->clique_base_annotation_done)
+ return 0;
+
+ set_points_to_info = false;
}
/* For each pointer P_i, determine the sets of variables that P_i may
point-to. Compute the reachability set of escaped and call-used
variables. */
- compute_points_to_sets ();
+ compute_points_to_sets (set_points_to_info);
/* Debugging dumps. */
if (dump_file)
@@ -7314,6 +7323,7 @@ compute_may_aliases (void)
/* Compute restrict-based memory disambiguations. */
compute_dependence_clique ();
+ cfun->gimple_df->clique_base_annotation_done = true;
/* Deallocate memory used by aliasing data structures and the internal
points-to solution. */
@@ -7816,3 +7826,47 @@ make_pass_ipa_pta (gcc::context *ctxt)
{
return new pass_ipa_pta (ctxt);
}
+
+namespace {
+
+const pass_data pass_data_ipa_pta_oacc_kernels =
+{
+ SIMPLE_IPA_PASS, /* type */
+ "pta_oacc_kernels", /* name */
+ OPTGROUP_NONE, /* optinfo_flags */
+ TV_IPA_PTA, /* tv_id */
+ 0, /* properties_required */
+ 0, /* properties_provided */
+ 0, /* properties_destroyed */
+ 0, /* todo_flags_start */
+ 0, /* todo_flags_finish */
+};
+
+class pass_ipa_pta_oacc_kernels : public simple_ipa_opt_pass
+{
+public:
+ pass_ipa_pta_oacc_kernels (gcc::context *ctxt)
+ : simple_ipa_opt_pass (pass_data_ipa_pta_oacc_kernels, ctxt)
+ {}
+
+ /* opt_pass methods: */
+ virtual bool gate (function *)
+ {
+ return (optimize
+ && flag_openacc
+ && flag_tree_parallelize_loops > 1
+ /* Don't bother doing anything if the program has errors. */
+ && !seen_error ());
+ }
+
+ virtual unsigned int execute (function *) { return ipa_pta_execute (); }
+
+}; // class pass_ipa_pta_oacc_kernels
+
+} // anon namespace
+
+simple_ipa_opt_pass *
+make_pass_ipa_pta_oacc_kernels (gcc::context *ctxt)
+{
+ return new pass_ipa_pta_oacc_kernels (ctxt);
+}