gcc/ChangeLog.gimple-classes: * gimple.h (gimple_omp_sections_clauses): Strengthen param from const_gimple to const gomp_sections *. (gimple_omp_sections_control): Likewise. (gimple_omp_sections_clauses_ptr): Strengthen param from gimple to gomp_sections *. (gimple_omp_sections_set_clauses): Likewise. (gimple_omp_sections_control_ptr): Likewise. (gimple_omp_sections_set_control): Likewise.
* gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_SECTIONS, introduce local "omp_sections_stmt" via a checked cast and use it in place of "stmt" for typesafety. * gimple.c (gimple_copy): Likewise, introducing locals "omp_sections_stmt" and "omp_sections_copy", using them in place of "stmt" and "copy". * omp-low.c (check_omp_nesting_restrictions): Add checked casts. * tree-inline.c (remap_gimple_stmt): Within case GIMPLE_OMP_SECTIONS, introduce local "omp_sections_stmt" via a checked cast and use it in place of "stmt" for typesafety. * tree-nested.c (convert_nonlocal_reference_stmt): Likewise. (convert_local_reference_stmt): Likewise. --- gcc/ChangeLog.gimple-classes | 24 ++++++++++++++++++++++++ gcc/gimple-walk.c | 20 +++++++++++--------- gcc/gimple.c | 12 ++++++++---- gcc/gimple.h | 37 +++++++++++++------------------------ gcc/omp-low.c | 14 ++++++++------ gcc/tree-inline.c | 9 ++++++--- gcc/tree-nested.c | 31 +++++++++++++++++++++---------- 7 files changed, 91 insertions(+), 56 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 626ea2f..469c009 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,29 @@ 2014-10-29 David Malcolm <dmalc...@redhat.com> + * gimple.h (gimple_omp_sections_clauses): Strengthen param from + const_gimple to const gomp_sections *. + (gimple_omp_sections_control): Likewise. + (gimple_omp_sections_clauses_ptr): Strengthen param from gimple to + gomp_sections *. + (gimple_omp_sections_set_clauses): Likewise. + (gimple_omp_sections_control_ptr): Likewise. + (gimple_omp_sections_set_control): Likewise. + + * gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_SECTIONS, + introduce local "omp_sections_stmt" via a checked cast and use it + in place of "stmt" for typesafety. + * gimple.c (gimple_copy): Likewise, introducing locals + "omp_sections_stmt" and "omp_sections_copy", using them in place + of "stmt" and "copy". + * omp-low.c (check_omp_nesting_restrictions): Add checked casts. + * tree-inline.c (remap_gimple_stmt): Within case + GIMPLE_OMP_SECTIONS, introduce local "omp_sections_stmt" via a + checked cast and use it in place of "stmt" for typesafety. + * tree-nested.c (convert_nonlocal_reference_stmt): Likewise. + (convert_local_reference_stmt): Likewise. + +2014-10-29 David Malcolm <dmalc...@redhat.com> + * gimple.h (gimple_omp_teams_clauses): Strengthen param from const_gimple to const gomp_teams *. (gimple_omp_teams_clauses_ptr): Strengthen param from gimple to diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c index 13c16bb..b802c95 100644 --- a/gcc/gimple-walk.c +++ b/gcc/gimple-walk.c @@ -406,16 +406,18 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op, break; case GIMPLE_OMP_SECTIONS: - ret = walk_tree (gimple_omp_sections_clauses_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; - - ret = walk_tree (gimple_omp_sections_control_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; + { + gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt); + ret = walk_tree (gimple_omp_sections_clauses_ptr (omp_sections_stmt), callback_op, + wi, pset); + if (ret) + return ret; + ret = walk_tree (gimple_omp_sections_control_ptr (omp_sections_stmt), callback_op, + wi, pset); + if (ret) + return ret; + } break; case GIMPLE_OMP_SINGLE: diff --git a/gcc/gimple.c b/gcc/gimple.c index f02930d..b34ac10 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1797,10 +1797,14 @@ gimple_copy (gimple stmt) goto copy_omp_body; case GIMPLE_OMP_SECTIONS: - t = unshare_expr (gimple_omp_sections_clauses (stmt)); - gimple_omp_sections_set_clauses (copy, t); - t = unshare_expr (gimple_omp_sections_control (stmt)); - gimple_omp_sections_set_control (copy, t); + { + gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt); + gomp_sections *omp_sections_copy = as_a <gomp_sections *> (copy); + t = unshare_expr (gimple_omp_sections_clauses (omp_sections_stmt)); + gimple_omp_sections_set_clauses (omp_sections_copy, t); + t = unshare_expr (gimple_omp_sections_control (omp_sections_stmt)); + gimple_omp_sections_set_control (omp_sections_copy, t); + } /* FALLTHRU */ case GIMPLE_OMP_SINGLE: diff --git a/gcc/gimple.h b/gcc/gimple.h index 41f1691..723c2f5 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -5105,72 +5105,61 @@ gimple_omp_teams_set_clauses (gomp_teams *omp_teams_stmt, tree clauses) } -/* Return the clauses associated with OMP_SECTIONS GS. */ +/* Return the clauses associated with OMP_SECTIONS OMP_SECTIONS_STMT. */ static inline tree -gimple_omp_sections_clauses (const_gimple gs) +gimple_omp_sections_clauses (const gomp_sections *omp_sections_stmt) { - const gomp_sections *omp_sections_stmt = - as_a <const gomp_sections *> (gs); return omp_sections_stmt->clauses; } -/* Return a pointer to the clauses associated with OMP_SECTIONS GS. */ +/* Return a pointer to the clauses associated with OMP_SECTIONS + OMP_SECTIONS_STMT. */ static inline tree * -gimple_omp_sections_clauses_ptr (gimple gs) +gimple_omp_sections_clauses_ptr (gomp_sections *omp_sections_stmt) { - gomp_sections *omp_sections_stmt = - as_a <gomp_sections *> (gs); return &omp_sections_stmt->clauses; } /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS - GS. */ + OMP_SECTIONS_STMT. */ static inline void -gimple_omp_sections_set_clauses (gimple gs, tree clauses) +gimple_omp_sections_set_clauses (gomp_sections *omp_sections_stmt, tree clauses) { - gomp_sections *omp_sections_stmt = - as_a <gomp_sections *> (gs); omp_sections_stmt->clauses = clauses; } /* Return the control variable associated with the GIMPLE_OMP_SECTIONS - in GS. */ + in OMP_SECTIONS_STMT. */ static inline tree -gimple_omp_sections_control (const_gimple gs) +gimple_omp_sections_control (const gomp_sections *omp_sections_stmt) { - const gomp_sections *omp_sections_stmt = - as_a <const gomp_sections *> (gs); return omp_sections_stmt->control; } /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS - GS. */ + OMP_SECTIONS_STMT. */ static inline tree * -gimple_omp_sections_control_ptr (gimple gs) +gimple_omp_sections_control_ptr (gomp_sections *omp_sections_stmt) { - gomp_sections *omp_sections_stmt = - as_a <gomp_sections *> (gs); return &omp_sections_stmt->control; } /* Set CONTROL to be the set of clauses associated with the - GIMPLE_OMP_SECTIONS in GS. */ + GIMPLE_OMP_SECTIONS in OMP_SECTIONS_STMT. */ static inline void -gimple_omp_sections_set_control (gimple gs, tree control) +gimple_omp_sections_set_control (gomp_sections *omp_sections_stmt, tree control) { - gomp_sections *omp_sections_stmt = - as_a <gomp_sections *> (gs); omp_sections_stmt->control = control; } diff --git a/gcc/omp-low.c b/gcc/omp-low.c index c43f5ea..509f3f8 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2516,9 +2516,10 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx) if (gimple_code (ctx->stmt) == GIMPLE_OMP_SECTIONS) { ctx->cancellable = true; - if (find_omp_clause (gimple_omp_sections_clauses - (ctx->stmt), - OMP_CLAUSE_NOWAIT)) + if (find_omp_clause ( + gimple_omp_sections_clauses ( + as_a <gomp_sections *> (ctx->stmt)), + OMP_CLAUSE_NOWAIT)) warning_at (gimple_location (stmt), 0, "%<#pragma omp cancel sections%> inside " "%<nowait%> sections construct"); @@ -2529,9 +2530,10 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx) && gimple_code (ctx->outer->stmt) == GIMPLE_OMP_SECTIONS); ctx->outer->cancellable = true; - if (find_omp_clause (gimple_omp_sections_clauses - (ctx->outer->stmt), - OMP_CLAUSE_NOWAIT)) + if (find_omp_clause ( + gimple_omp_sections_clauses ( + as_a <gomp_sections *> (ctx->outer->stmt)), + OMP_CLAUSE_NOWAIT)) warning_at (gimple_location (stmt), 0, "%<#pragma omp cancel sections%> inside " "%<nowait%> sections construct"); diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 6498e23..bc19939 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1455,9 +1455,12 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) break; case GIMPLE_OMP_SECTIONS: - s1 = remap_gimple_seq (gimple_omp_body (stmt), id); - copy = gimple_build_omp_sections - (s1, gimple_omp_sections_clauses (stmt)); + { + gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt); + s1 = remap_gimple_seq (gimple_omp_body (omp_sections_stmt), id); + copy = gimple_build_omp_sections ( + s1, gimple_omp_sections_clauses (omp_sections_stmt)); + } break; case GIMPLE_OMP_SINGLE: diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 3463151..f0756c1 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -1365,11 +1365,17 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, break; case GIMPLE_OMP_SECTIONS: - save_suppress = info->suppress_expansion; - convert_nonlocal_omp_clauses (gimple_omp_sections_clauses_ptr (stmt), wi); - walk_body (convert_nonlocal_reference_stmt, convert_nonlocal_reference_op, - info, gimple_omp_body_ptr (stmt)); - info->suppress_expansion = save_suppress; + { + gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt); + save_suppress = info->suppress_expansion; + convert_nonlocal_omp_clauses (gimple_omp_sections_clauses_ptr ( + omp_sections_stmt), + wi); + walk_body (convert_nonlocal_reference_stmt, + convert_nonlocal_reference_op, + info, gimple_omp_body_ptr (omp_sections_stmt)); + info->suppress_expansion = save_suppress; + } break; case GIMPLE_OMP_SINGLE: @@ -1944,11 +1950,16 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, break; case GIMPLE_OMP_SECTIONS: - save_suppress = info->suppress_expansion; - convert_local_omp_clauses (gimple_omp_sections_clauses_ptr (stmt), wi); - walk_body (convert_local_reference_stmt, convert_local_reference_op, - info, gimple_omp_body_ptr (stmt)); - info->suppress_expansion = save_suppress; + { + gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt); + save_suppress = info->suppress_expansion; + convert_local_omp_clauses (gimple_omp_sections_clauses_ptr ( + omp_sections_stmt), + wi); + walk_body (convert_local_reference_stmt, convert_local_reference_op, + info, gimple_omp_body_ptr (omp_sections_stmt)); + info->suppress_expansion = save_suppress; + } break; case GIMPLE_OMP_SINGLE: -- 1.7.11.7