From patchwork Wed Oct 29 18:47:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 404772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A1BEC14007D for ; Thu, 30 Oct 2014 06:09:22 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=WcZRsQFxiNviT8S7Rwu63iMeUgyojI8kEiatWWwj/zX5YSBT4pb9F Tp9ZFzonp5PJsxxGkncCyBxhmrY29XZJ56W4pdMmrfKi45+6d76gkgYQIyyobryh 1r+yduBsQ0PprW/v4iJMyP7lpJY9XmcyeJmtjAwIJtI0tixWVS8K6A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=END0eas+LOczifISrJ2A1hmsiTs=; b=ymROoDpuX+MSq/e+hIrl ClSdm84GPO6QNzydHUy4SK5CzJhjh+v/FUNiTrD8w5KPSO+Fel6yFpOr+p6on8IU L/O7SKIY17g/829Oe6rR7l7JecGJbIixQCHWbn2/+dGIlADc8YYzWkEWCnbBwg5I c7mrcArgDFzXuUdp9zbiI00= Received: (qmail 25792 invoked by alias); 29 Oct 2014 19:09:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 25780 invoked by uid 89); 29 Oct 2014 19:09:15 -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 autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 29 Oct 2014 19:09:13 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjYM0-0002Ea-Cd for gcc-patches@gcc.gnu.org; Wed, 29 Oct 2014 14:52:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjYM0-0002EU-50 for gcc-patches@gcc.gnu.org; Wed, 29 Oct 2014 14:52:20 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9TIqJjn007538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 29 Oct 2014 14:52:19 -0400 Received: from surprise.redhat.com (vpn-235-224.phx2.redhat.com [10.3.235.224]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9TIqDvu028359; Wed, 29 Oct 2014 14:52:18 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 08/10] Make remainging gimple_omp_parallel_ accessors typesafe Date: Wed, 29 Oct 2014 14:47:58 -0400 Message-Id: <1414608480-32461-9-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1414608480-32461-1-git-send-email-dmalcolm@redhat.com> References: <1414608480-32461-1-git-send-email-dmalcolm@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-IsSubscribed: yes gcc/ChangeLog.gimple-classes: * gimple.h (gimple_omp_parallel_combined_p): Strengthen param from const_gimple to const gomp_parallel *. (gimple_omp_parallel_clauses): Likewise. (gimple_omp_parallel_set_combined_p): Strengthen param from gimple to gomp_parallel *. * omp-low.c (get_ws_args_for): Add checked cast. (determine_parallel_type): Likewise. (create_omp_child_function): Likewise. (lower_lastprivate_clauses): Likewise. (expand_omp_taskreg): Likewise. (expand_omp_for_init_vars): Likewise. (expand_omp_for_static_nochunk): Likewise. (expand_omp_for_static_chunk): Likewise. (lower_omp_for): Likewise. (lower_omp_taskreg): Replace check against GIMPLE_OMP_PARALLEL with a dyn_cast, introducing local "par_stmt" and using it in place of "stmt" for typesafety. --- gcc/ChangeLog.gimple-classes | 21 +++++++++++++++++ gcc/gimple.h | 12 ++++------ gcc/omp-low.c | 56 ++++++++++++++++++++++++++------------------ 3 files changed, 58 insertions(+), 31 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index cc8b97b..e8001f4 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,26 @@ 2014-10-29 David Malcolm + * gimple.h (gimple_omp_parallel_combined_p): Strengthen param from + const_gimple to const gomp_parallel *. + (gimple_omp_parallel_clauses): Likewise. + (gimple_omp_parallel_set_combined_p): Strengthen param from gimple + to gomp_parallel *. + + * omp-low.c (get_ws_args_for): Add checked cast. + (determine_parallel_type): Likewise. + (create_omp_child_function): Likewise. + (lower_lastprivate_clauses): Likewise. + (expand_omp_taskreg): Likewise. + (expand_omp_for_init_vars): Likewise. + (expand_omp_for_static_nochunk): Likewise. + (expand_omp_for_static_chunk): Likewise. + (lower_omp_for): Likewise. + (lower_omp_taskreg): Replace check against GIMPLE_OMP_PARALLEL + with a dyn_cast, introducing local "par_stmt" and using it in + place of "stmt" for typesafety. + +2014-10-29 David Malcolm + * gimple.h (gimple_omp_target_clauses): Strengthen param from const_gimple to const gomp_target *. (gimple_omp_target_kind): Likewise. diff --git a/gcc/gimple.h b/gcc/gimple.h index 3220f9a..4e86476 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -2097,9 +2097,8 @@ gimple_omp_section_set_last (gimple g) GF_OMP_PARALLEL_COMBINED flag set. */ static inline bool -gimple_omp_parallel_combined_p (const_gimple g) +gimple_omp_parallel_combined_p (const gomp_parallel *g) { - GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL); return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0; } @@ -2108,9 +2107,8 @@ gimple_omp_parallel_combined_p (const_gimple g) value of COMBINED_P. */ static inline void -gimple_omp_parallel_set_combined_p (gimple g, bool combined_p) +gimple_omp_parallel_set_combined_p (gomp_parallel *g, bool combined_p) { - GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL); if (combined_p) g->subcode |= GF_OMP_PARALLEL_COMBINED; else @@ -4573,13 +4571,11 @@ gimple_omp_for_set_pre_body (gomp_for *omp_for_stmt, gimple_seq pre_body) } -/* Return the clauses associated with OMP_PARALLEL GS. */ +/* Return the clauses associated with OMP_PARALLEL OMP_PARALLEL_STMT. */ static inline tree -gimple_omp_parallel_clauses (const_gimple gs) +gimple_omp_parallel_clauses (const gomp_parallel *omp_parallel_stmt) { - const gomp_parallel *omp_parallel_stmt = - as_a (gs); return omp_parallel_stmt->clauses; } diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 21eee0f..6e0db88 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -693,7 +693,8 @@ get_ws_args_for (gimple par_stmt, gimple ws_stmt) if (gimple_omp_for_combined_into_p (for_stmt)) { tree innerc - = find_omp_clause (gimple_omp_parallel_clauses (par_stmt), + = find_omp_clause (gimple_omp_parallel_clauses ( + as_a (par_stmt)), OMP_CLAUSE__LOOPTEMP_); gcc_assert (innerc); n1 = OMP_CLAUSE_DECL (innerc); @@ -767,7 +768,8 @@ determine_parallel_type (struct omp_region *region) if (single_succ (par_entry_bb) == ws_entry_bb && single_succ (ws_exit_bb) == par_exit_bb && workshare_safe_to_combine_p (ws_entry_bb) - && (gimple_omp_parallel_combined_p (last_stmt (par_entry_bb)) + && (gimple_omp_parallel_combined_p (as_a ( + last_stmt (par_entry_bb))) || (last_and_only_stmt (ws_entry_bb) && last_and_only_stmt (par_exit_bb)))) { @@ -1901,7 +1903,8 @@ create_omp_child_function (omp_context *ctx, bool task_copy) tree cilk_for_count = (flag_cilkplus && gimple_code (ctx->stmt) == GIMPLE_OMP_PARALLEL) - ? find_omp_clause (gimple_omp_parallel_clauses (ctx->stmt), + ? find_omp_clause (gimple_omp_parallel_clauses ( + as_a (ctx->stmt)), OMP_CLAUSE__CILK_FOR_COUNT_) : NULL_TREE; tree cilk_var_type = NULL_TREE; @@ -3967,7 +3970,8 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list, if (ctx == NULL || !is_parallel_ctx (ctx)) return; - clauses = find_omp_clause (gimple_omp_parallel_clauses (ctx->stmt), + clauses = find_omp_clause (gimple_omp_parallel_clauses ( + as_a (ctx->stmt)), OMP_CLAUSE_LASTPRIVATE); if (clauses == NULL) return; @@ -4072,7 +4076,8 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list, if (ctx == NULL || !is_parallel_ctx (ctx)) break; - c = find_omp_clause (gimple_omp_parallel_clauses (ctx->stmt), + c = find_omp_clause (gimple_omp_parallel_clauses ( + as_a (ctx->stmt)), OMP_CLAUSE_LASTPRIVATE); par_clauses = true; } @@ -4938,7 +4943,8 @@ expand_omp_taskreg (struct omp_region *region) bool is_cilk_for = (flag_cilkplus && gimple_code (entry_stmt) == GIMPLE_OMP_PARALLEL - && find_omp_clause (gimple_omp_parallel_clauses (entry_stmt), + && find_omp_clause (gimple_omp_parallel_clauses ( + as_a (entry_stmt)), OMP_CLAUSE__CILK_FOR_COUNT_) != NULL_TREE); if (is_cilk_for) @@ -5381,7 +5387,8 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi, return; tree clauses = gimple_code (inner_stmt) == GIMPLE_OMP_PARALLEL - ? gimple_omp_parallel_clauses (inner_stmt) + ? gimple_omp_parallel_clauses ( + as_a (inner_stmt)) : gimple_omp_for_clauses (as_a (inner_stmt)); /* First two _looptemp_ clauses are for istart/iend, counts[0] isn't supposed to be handled, as the inner loop doesn't @@ -6256,7 +6263,8 @@ expand_omp_for_static_nochunk (struct omp_region *region, if (gimple_omp_for_combined_p (fd->for_stmt)) { tree clauses = gimple_code (inner_stmt) == GIMPLE_OMP_PARALLEL - ? gimple_omp_parallel_clauses (inner_stmt) + ? gimple_omp_parallel_clauses ( + as_a (inner_stmt)) : gimple_omp_for_clauses (as_a (inner_stmt)); tree innerc = find_omp_clause (clauses, OMP_CLAUSE__LOOPTEMP_); gcc_assert (innerc); @@ -6648,7 +6656,8 @@ expand_omp_for_static_chunk (struct omp_region *region, if (gimple_omp_for_combined_p (fd->for_stmt)) { tree clauses = gimple_code (inner_stmt) == GIMPLE_OMP_PARALLEL - ? gimple_omp_parallel_clauses (inner_stmt) + ? gimple_omp_parallel_clauses ( + as_a (inner_stmt)) : gimple_omp_for_clauses (as_a (inner_stmt)); tree innerc = find_omp_clause (clauses, OMP_CLAUSE__LOOPTEMP_); gcc_assert (innerc); @@ -9508,7 +9517,8 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx) tree clauses = *pc; if (parallel_for) outerc - = find_omp_clause (gimple_omp_parallel_clauses (ctx->outer->stmt), + = find_omp_clause (gimple_omp_parallel_clauses ( + as_a (ctx->outer->stmt)), OMP_CLAUSE__LOOPTEMP_); for (i = 0; i < count; i++) { @@ -9986,19 +9996,19 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx) as_a (gimple_seq_first_stmt (gimple_omp_body (stmt))); par_body = gimple_bind_body (par_bind); child_fn = ctx->cb.dst_fn; - if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL - && !gimple_omp_parallel_combined_p (stmt)) - { - struct walk_stmt_info wi; - int ws_num = 0; - - memset (&wi, 0, sizeof (wi)); - wi.info = &ws_num; - wi.val_only = true; - walk_gimple_seq (par_body, check_combined_parallel, NULL, &wi); - if (ws_num == 1) - gimple_omp_parallel_set_combined_p (stmt, true); - } + if (gomp_parallel *par_stmt = dyn_cast (stmt)) + if (!gimple_omp_parallel_combined_p (par_stmt)) + { + struct walk_stmt_info wi; + int ws_num = 0; + + memset (&wi, 0, sizeof (wi)); + wi.info = &ws_num; + wi.val_only = true; + walk_gimple_seq (par_body, check_combined_parallel, NULL, &wi); + if (ws_num == 1) + gimple_omp_parallel_set_combined_p (par_stmt, true); + } gimple_seq dep_ilist = NULL; gimple_seq dep_olist = NULL; if (gimple_code (stmt) == GIMPLE_OMP_TASK