From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101584 invoked by alias); 11 Dec 2015 12:45:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 101389 invoked by uid 89); 11 Dec 2015 12:45:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 11 Dec 2015 12:45:49 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37593) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1a7N50-0005Ps-OM for gcc-patches@gnu.org; Fri, 11 Dec 2015 07:45:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7N4x-0002SE-0J for gcc-patches@gnu.org; Fri, 11 Dec 2015 07:45:46 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:64534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7N4w-0002SA-HI for gcc-patches@gnu.org; Fri, 11 Dec 2015 07:45:42 -0500 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 1a7N4t-0004Wg-U3 from Tom_deVries@mentor.com ; Fri, 11 Dec 2015 04:45:40 -0800 Received: from [127.0.0.1] (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; Fri, 11 Dec 2015 12:45:37 +0000 Subject: Re: [PATCH, 4/16] Implement -foffload-alias To: Jakub Jelinek , Richard Biener References: <5640BD31.2060602@mentor.com> <5640C560.1000007@mentor.com> <20151111110034.GF5675@tucnak.redhat.com> <5644B84D.6050504@mentor.com> <5645C33B.9080802@mentor.com> <20151113113938.GM5675@tucnak.redhat.com> CC: "gcc-patches@gnu.org" From: Tom de Vries Message-ID: <566AC56E.8050701@mentor.com> Date: Fri, 11 Dec 2015 12:45:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151113113938.GM5675@tucnak.redhat.com> Content-Type: multipart/mixed; boundary="------------010609090007090700010401" X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 X-SW-Source: 2015-12/txt/msg01257.txt.bz2 --------------010609090007090700010401 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1612 On 13/11/15 12:39, Jakub Jelinek wrote: > We simply have some compiler internal interface between the caller and > callee of the outlined regions, each interface in between those has > its own structure type used to communicate the info; > we can attach attributes on the fields, or some flags to indicate some > properties interesting from aliasing POV. We don't really need to perform > full IPA-PTA, perhaps it would be enough to a) record somewhere in cgraph > the relationship in between such callers and callees (for offloading regions > we already have "omp target entrypoint" attribute on the callee and a > singler caller), tell LTO if possible not to split those into different > partitions if easily possible, and then just for these pairs perform > aliasing/points-to analysis in the caller and the result record using > cliques/special attributes/whatever to the callee side, so that the callee > (outlined OpenMP/OpenACC/Cilk+ region) can then improve its alias analysis. Hi, This work-in-progress patch allows me to use IPA PTA information in the kernels pass group. Since: - I'm running IPA PTA before ealias, and IPA PTA does not interpret restrict, and - compute_may_alias doesn't run if IPA PTA information is present I needed to convince ealias to do the restrict clique/base annotation. It would be more logical to fit IPA PTA after ealias, but one is an IPA pass, the other a regular one-function pass, so I would have to split the containing pass groups pass_all_early_optimizations and pass_local_optimization_passes. I'll give that a try now. Any comments? Thanks, - Tom --------------010609090007090700010401 Content-Type: text/x-patch; name="0008-Run-pass_ipa_pta-before-pass_local_optimization_passes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0008-Run-pass_ipa_pta-before-pass_local_optimization_passes."; filename*1="patch" Content-length: 5025 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(-) diff --git a/gcc/gimple-ssa.h b/gcc/gimple-ssa.h index 39551da..aff2fb7 100644 --- a/gcc/gimple-ssa.h +++ b/gcc/gimple-ssa.h @@ -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 * GTY((skip(""))) decls_to_pointers; diff --git a/gcc/passes.def b/gcc/passes.def index 678a900..5293be0 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -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); diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 4566d33..980922e 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -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); diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 7420ce1..dfc0422 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -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); +} --------------010609090007090700010401--