diff options
author | David Malcolm <dmalcolm@redhat.com> | 2014-10-29 10:38:25 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2014-10-29 10:38:25 -0400 |
commit | a0ba467fce77734cb75f8710789e95215dc86472 (patch) | |
tree | 1f0e0b62aed443bb8b9e6d3e9dcb3636dd1272ad | |
parent | 6167458f40f55bd6b9387309ae0730349b7b3b52 (diff) | |
download | gcc-a0ba467fce77734cb75f8710789e95215dc86472.tar.gz |
Make all of gimple_omp_task_ accessors typesafe
gcc/ChangeLog.gimple-classes:
* gimple.h (gimple_omp_task_clauses): Strengthen param from
const_gimple to const gomp_task *.
(gimple_omp_task_child_fn): Likewise.
(gimple_omp_task_data_arg): Likewise.
(gimple_omp_task_copy_fn): Likewise.
(gimple_omp_task_arg_size): Likewise.
(gimple_omp_task_arg_align): Likewise.
(gimple_omp_task_clauses_ptr): Strengthen param from gimple to
gomp_task *.
(gimple_omp_task_set_clauses): Likewise.
(gimple_omp_task_child_fn_ptr): Likewise.
(gimple_omp_task_set_child_fn): Likewise.
(gimple_omp_task_data_arg_ptr): Likewise.
(gimple_omp_task_set_data_arg): Likewise.
(gimple_omp_task_copy_fn_ptr): Likewise.
(gimple_omp_task_set_copy_fn): Likewise.
(gimple_omp_task_arg_size_ptr): Likewise.
(gimple_omp_task_set_arg_size): Likewise.
(gimple_omp_task_arg_align_ptr): Likewise.
(gimple_omp_task_set_arg_align): Likewise.
* cgraphbuild.c (pass_build_cgraph_edges::execute): Replace check
for GIMPLE_OMP_TASK with a dyn_cast, introducing local "omp_task"
and using it in place of "stmt" for typesafety.
* gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_TASK,
introduce local "omp_task" via a checked cast, using it in place
of "stmt" for typesafety.
* gimple.c (gimple_copy): Likewise, introducing locals
"omp_task_stmt" and "omp_task_copy".
* omp-low.c (create_omp_child_function): Add a checked cast.
(finish_taskreg_scan): Add checked casts.
(optimize_omp_library_calls): Add a checked cast.
(lower_depend_clauses): Strengthen param "stmt" from gimple to
gomp_task *.
(lower_omp_taskreg): Add a checked cast.
* tree-inline.c (remap_gimple_stmt): Within case GIMPLE_OMP_TASK,
introduce local "omp_task_stmt" via a checked cast, using it in
place of "stmt" for typesafety.
-rw-r--r-- | gcc/ChangeLog.gimple-classes | 41 | ||||
-rw-r--r-- | gcc/cgraphbuild.c | 6 | ||||
-rw-r--r-- | gcc/gimple-walk.c | 51 | ||||
-rw-r--r-- | gcc/gimple.c | 28 | ||||
-rw-r--r-- | gcc/gimple.h | 111 | ||||
-rw-r--r-- | gcc/omp-low.c | 13 | ||||
-rw-r--r-- | gcc/tree-inline.c | 21 |
7 files changed, 145 insertions, 126 deletions
diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 10c3957f7c0..07ebee71c59 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,3 +1,44 @@ +2014-10-29 David Malcolm <dmalcolm@redhat.com> + + * gimple.h (gimple_omp_task_clauses): Strengthen param from + const_gimple to const gomp_task *. + (gimple_omp_task_child_fn): Likewise. + (gimple_omp_task_data_arg): Likewise. + (gimple_omp_task_copy_fn): Likewise. + (gimple_omp_task_arg_size): Likewise. + (gimple_omp_task_arg_align): Likewise. + (gimple_omp_task_clauses_ptr): Strengthen param from gimple to + gomp_task *. + (gimple_omp_task_set_clauses): Likewise. + (gimple_omp_task_child_fn_ptr): Likewise. + (gimple_omp_task_set_child_fn): Likewise. + (gimple_omp_task_data_arg_ptr): Likewise. + (gimple_omp_task_set_data_arg): Likewise. + (gimple_omp_task_copy_fn_ptr): Likewise. + (gimple_omp_task_set_copy_fn): Likewise. + (gimple_omp_task_arg_size_ptr): Likewise. + (gimple_omp_task_set_arg_size): Likewise. + (gimple_omp_task_arg_align_ptr): Likewise. + (gimple_omp_task_set_arg_align): Likewise. + + * cgraphbuild.c (pass_build_cgraph_edges::execute): Replace check + for GIMPLE_OMP_TASK with a dyn_cast, introducing local "omp_task" + and using it in place of "stmt" for typesafety. + * gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_TASK, + introduce local "omp_task" via a checked cast, using it in place + of "stmt" for typesafety. + * gimple.c (gimple_copy): Likewise, introducing locals + "omp_task_stmt" and "omp_task_copy". + * omp-low.c (create_omp_child_function): Add a checked cast. + (finish_taskreg_scan): Add checked casts. + (optimize_omp_library_calls): Add a checked cast. + (lower_depend_clauses): Strengthen param "stmt" from gimple to + gomp_task *. + (lower_omp_taskreg): Add a checked cast. + * tree-inline.c (remap_gimple_stmt): Within case GIMPLE_OMP_TASK, + introduce local "omp_task_stmt" via a checked cast, using it in + place of "stmt" for typesafety. + 2014-10-28 David Malcolm <dmalcolm@redhat.com> * gimple.h (gimple_try_kind): Strengthen param from const_gimple diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c index 32319a6292b..8d44002cb1f 100644 --- a/gcc/cgraphbuild.c +++ b/gcc/cgraphbuild.c @@ -369,13 +369,13 @@ pass_build_cgraph_edges::execute (function *fun) node->create_reference (cgraph_node::get_create (fn), IPA_REF_ADDR, stmt); } - if (gimple_code (stmt) == GIMPLE_OMP_TASK) + if (gomp_task *omp_task = dyn_cast <gomp_task *> (stmt)) { - tree fn = gimple_omp_task_child_fn (stmt); + tree fn = gimple_omp_task_child_fn (omp_task); if (fn) node->create_reference (cgraph_node::get_create (fn), IPA_REF_ADDR, stmt); - fn = gimple_omp_task_copy_fn (stmt); + fn = gimple_omp_task_copy_fn (omp_task); if (fn) node->create_reference (cgraph_node::get_create (fn), IPA_REF_ADDR, stmt); diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c index 1248e7595b3..020e55f6b6b 100644 --- a/gcc/gimple-walk.c +++ b/gcc/gimple-walk.c @@ -373,30 +373,33 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op, break; case GIMPLE_OMP_TASK: - ret = walk_tree (gimple_omp_task_clauses_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; - ret = walk_tree (gimple_omp_task_child_fn_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; - ret = walk_tree (gimple_omp_task_data_arg_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; - ret = walk_tree (gimple_omp_task_copy_fn_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; - ret = walk_tree (gimple_omp_task_arg_size_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; - ret = walk_tree (gimple_omp_task_arg_align_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; + { + gomp_task *omp_task = as_a <gomp_task *> (stmt); + ret = walk_tree (gimple_omp_task_clauses_ptr (omp_task), callback_op, + wi, pset); + if (ret) + return ret; + ret = walk_tree (gimple_omp_task_child_fn_ptr (omp_task), callback_op, + wi, pset); + if (ret) + return ret; + ret = walk_tree (gimple_omp_task_data_arg_ptr (omp_task), callback_op, + wi, pset); + if (ret) + return ret; + ret = walk_tree (gimple_omp_task_copy_fn_ptr (omp_task), callback_op, + wi, pset); + if (ret) + return ret; + ret = walk_tree (gimple_omp_task_arg_size_ptr (omp_task), callback_op, + wi, pset); + if (ret) + return ret; + ret = walk_tree (gimple_omp_task_arg_align_ptr (omp_task), callback_op, + wi, pset); + if (ret) + return ret; + } break; case GIMPLE_OMP_SECTIONS: diff --git a/gcc/gimple.c b/gcc/gimple.c index c6d0f7a3a2d..7021300605e 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1771,18 +1771,22 @@ gimple_copy (gimple stmt) goto copy_omp_body; case GIMPLE_OMP_TASK: - t = unshare_expr (gimple_omp_task_clauses (stmt)); - gimple_omp_task_set_clauses (copy, t); - t = unshare_expr (gimple_omp_task_child_fn (stmt)); - gimple_omp_task_set_child_fn (copy, t); - t = unshare_expr (gimple_omp_task_data_arg (stmt)); - gimple_omp_task_set_data_arg (copy, t); - t = unshare_expr (gimple_omp_task_copy_fn (stmt)); - gimple_omp_task_set_copy_fn (copy, t); - t = unshare_expr (gimple_omp_task_arg_size (stmt)); - gimple_omp_task_set_arg_size (copy, t); - t = unshare_expr (gimple_omp_task_arg_align (stmt)); - gimple_omp_task_set_arg_align (copy, t); + { + gomp_task *omp_task_stmt = as_a <gomp_task *> (stmt); + gomp_task *omp_task_copy = as_a <gomp_task *> (copy); + t = unshare_expr (gimple_omp_task_clauses (omp_task_stmt)); + gimple_omp_task_set_clauses (omp_task_copy, t); + t = unshare_expr (gimple_omp_task_child_fn (omp_task_stmt)); + gimple_omp_task_set_child_fn (omp_task_copy, t); + t = unshare_expr (gimple_omp_task_data_arg (omp_task_stmt)); + gimple_omp_task_set_data_arg (omp_task_copy, t); + t = unshare_expr (gimple_omp_task_copy_fn (omp_task_stmt)); + gimple_omp_task_set_copy_fn (omp_task_copy, t); + t = unshare_expr (gimple_omp_task_arg_size (omp_task_stmt)); + gimple_omp_task_set_arg_size (omp_task_copy, t); + t = unshare_expr (gimple_omp_task_arg_align (omp_task_stmt)); + gimple_omp_task_set_arg_align (omp_task_copy, t); + } goto copy_omp_body; case GIMPLE_OMP_CRITICAL: diff --git a/gcc/gimple.h b/gcc/gimple.h index 8e82914e8e7..ef1f4f79a4b 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -4707,103 +4707,87 @@ gimple_omp_parallel_set_data_arg (gomp_parallel *omp_parallel_stmt, } -/* Return the clauses associated with OMP_TASK GS. */ +/* Return the clauses associated with OMP_TASK OMP_TASK_STMT. */ static inline tree -gimple_omp_task_clauses (const_gimple gs) +gimple_omp_task_clauses (const gomp_task *omp_task_stmt) { - const gomp_task *omp_task_stmt = - as_a <const gomp_task *> (gs); return omp_task_stmt->clauses; } -/* Return a pointer to the clauses associated with OMP_TASK GS. */ +/* Return a pointer to the clauses associated with OMP_TASK + OMP_TASK_STMT. */ static inline tree * -gimple_omp_task_clauses_ptr (gimple gs) +gimple_omp_task_clauses_ptr (gomp_task *omp_task_stmt) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); return &omp_task_stmt->clauses; } /* Set CLAUSES to be the list of clauses associated with OMP_TASK - GS. */ + OMP_TASK_STMT. */ static inline void -gimple_omp_task_set_clauses (gimple gs, tree clauses) +gimple_omp_task_set_clauses (gomp_task *omp_task_stmt, tree clauses) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); omp_task_stmt->clauses = clauses; } -/* Return the child function used to hold the body of OMP_TASK GS. */ +/* Return the child function used to hold the body of OMP_TASK + OMP_TASK_STMT. */ static inline tree -gimple_omp_task_child_fn (const_gimple gs) +gimple_omp_task_child_fn (const gomp_task *omp_task_stmt) { - const gomp_task *omp_task_stmt = - as_a <const gomp_task *> (gs); return omp_task_stmt->child_fn; } /* Return a pointer to the child function used to hold the body of - OMP_TASK GS. */ + OMP_TASK OMP_TASK_STMT. */ static inline tree * -gimple_omp_task_child_fn_ptr (gimple gs) +gimple_omp_task_child_fn_ptr (gomp_task *omp_task_stmt) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); return &omp_task_stmt->child_fn; } -/* Set CHILD_FN to be the child function for OMP_TASK GS. */ +/* Set CHILD_FN to be the child function for OMP_TASK OMP_TASK_STMT. */ static inline void -gimple_omp_task_set_child_fn (gimple gs, tree child_fn) +gimple_omp_task_set_child_fn (gomp_task *omp_task_stmt, tree child_fn) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); omp_task_stmt->child_fn = child_fn; } /* Return the artificial argument used to send variables and values - from the parent to the children threads in OMP_TASK GS. */ + from the parent to the children threads in OMP_TASK OMP_TASK_STMT. */ static inline tree -gimple_omp_task_data_arg (const_gimple gs) +gimple_omp_task_data_arg (const gomp_task *omp_task_stmt) { - const gomp_task *omp_task_stmt = - as_a <const gomp_task *> (gs); return omp_task_stmt->data_arg; } -/* Return a pointer to the data argument for OMP_TASK GS. */ +/* Return a pointer to the data argument for OMP_TASK OMP_TASK_STMT. */ static inline tree * -gimple_omp_task_data_arg_ptr (gimple gs) +gimple_omp_task_data_arg_ptr (gomp_task *omp_task_stmt) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); return &omp_task_stmt->data_arg; } -/* Set DATA_ARG to be the data argument for OMP_TASK GS. */ +/* Set DATA_ARG to be the data argument for OMP_TASK OMP_TASK_STMT. */ static inline void -gimple_omp_task_set_data_arg (gimple gs, tree data_arg) +gimple_omp_task_set_data_arg (gomp_task *omp_task_stmt, tree data_arg) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); omp_task_stmt->data_arg = data_arg; } @@ -4909,101 +4893,84 @@ gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg) } -/* Return the copy function used to hold the body of OMP_TASK GS. */ +/* Return the copy function used to hold the body of OMP_TASK + OMP_TASK_STMT. */ static inline tree -gimple_omp_task_copy_fn (const_gimple gs) +gimple_omp_task_copy_fn (const gomp_task *omp_task_stmt) { - const gomp_task *omp_task_stmt = - as_a <const gomp_task *> (gs); return omp_task_stmt->copy_fn; } /* Return a pointer to the copy function used to hold the body of - OMP_TASK GS. */ + OMP_TASK OMP_TASK_STMT. */ static inline tree * -gimple_omp_task_copy_fn_ptr (gimple gs) +gimple_omp_task_copy_fn_ptr (gomp_task *omp_task_stmt) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); return &omp_task_stmt->copy_fn; } -/* Set CHILD_FN to be the copy function for OMP_TASK GS. */ +/* Set CHILD_FN to be the copy function for OMP_TASK OMP_TASK_STMT. */ static inline void -gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn) +gimple_omp_task_set_copy_fn (gomp_task *omp_task_stmt, tree copy_fn) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); omp_task_stmt->copy_fn = copy_fn; } -/* Return size of the data block in bytes in OMP_TASK GS. */ +/* Return size of the data block in bytes in OMP_TASK OMP_TASK_STMT. */ static inline tree -gimple_omp_task_arg_size (const_gimple gs) +gimple_omp_task_arg_size (const gomp_task *omp_task_stmt) { - const gomp_task *omp_task_stmt = - as_a <const gomp_task *> (gs); return omp_task_stmt->arg_size; } -/* Return a pointer to the data block size for OMP_TASK GS. */ +/* Return a pointer to the data block size for OMP_TASK OMP_TASK_STMT. */ static inline tree * -gimple_omp_task_arg_size_ptr (gimple gs) +gimple_omp_task_arg_size_ptr (gomp_task *omp_task_stmt) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); return &omp_task_stmt->arg_size; } -/* Set ARG_SIZE to be the data block size for OMP_TASK GS. */ +/* Set ARG_SIZE to be the data block size for OMP_TASK OMP_TASK_STMT. */ static inline void -gimple_omp_task_set_arg_size (gimple gs, tree arg_size) +gimple_omp_task_set_arg_size (gomp_task *omp_task_stmt, tree arg_size) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); omp_task_stmt->arg_size = arg_size; } -/* Return align of the data block in bytes in OMP_TASK GS. */ +/* Return align of the data block in bytes in OMP_TASK OMP_TASK_STMT. */ static inline tree -gimple_omp_task_arg_align (const_gimple gs) +gimple_omp_task_arg_align (const gomp_task *omp_task_stmt) { - const gomp_task *omp_task_stmt = - as_a <const gomp_task *> (gs); return omp_task_stmt->arg_align; } -/* Return a pointer to the data block align for OMP_TASK GS. */ +/* Return a pointer to the data block align for OMP_TASK OMP_TASK_STMT. */ static inline tree * -gimple_omp_task_arg_align_ptr (gimple gs) +gimple_omp_task_arg_align_ptr (gomp_task *omp_task_stmt) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); return &omp_task_stmt->arg_align; } -/* Set ARG_SIZE to be the data block align for OMP_TASK GS. */ +/* Set ARG_SIZE to be the data block align for OMP_TASK OMP_TASK_STMT. */ static inline void -gimple_omp_task_set_arg_align (gimple gs, tree arg_align) +gimple_omp_task_set_arg_align (gomp_task *omp_task_stmt, tree arg_align) { - gomp_task *omp_task_stmt = - as_a <gomp_task *> (gs); omp_task_stmt->arg_align = arg_align; } diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 0a5de1af9e9..2f28761edf1 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1922,7 +1922,7 @@ create_omp_child_function (omp_context *ctx, bool task_copy) if (!task_copy) ctx->cb.dst_fn = decl; else - gimple_omp_task_set_copy_fn (ctx->stmt, decl); + gimple_omp_task_set_copy_fn (as_a <gomp_task *> (ctx->stmt), decl); TREE_STATIC (decl) = 1; TREE_USED (decl) = 1; @@ -2271,10 +2271,10 @@ finish_taskreg_scan (omp_context *ctx) layout_type (ctx->srecord_type); tree t = fold_convert_loc (loc, long_integer_type_node, TYPE_SIZE_UNIT (ctx->record_type)); - gimple_omp_task_set_arg_size (ctx->stmt, t); + gimple_omp_task_set_arg_size (as_a <gomp_task *> (ctx->stmt), t); t = build_int_cst (long_integer_type_node, TYPE_ALIGN_UNIT (ctx->record_type)); - gimple_omp_task_set_arg_align (ctx->stmt, t); + gimple_omp_task_set_arg_align (as_a <gomp_task *> (ctx->stmt), t); } } @@ -4803,7 +4803,8 @@ optimize_omp_library_calls (gimple entry_stmt) tree num_thr_tree = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS); tree num_thr_id = DECL_ASSEMBLER_NAME (num_thr_tree); bool untied_task = (gimple_code (entry_stmt) == GIMPLE_OMP_TASK - && find_omp_clause (gimple_omp_task_clauses (entry_stmt), + && find_omp_clause (gimple_omp_task_clauses ( + as_a <gomp_task *> (entry_stmt)), OMP_CLAUSE_UNTIED) != NULL); FOR_EACH_BB_FN (bb, cfun) @@ -9870,7 +9871,7 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx) } static void -lower_depend_clauses (gimple stmt, gimple_seq *iseq, gimple_seq *oseq) +lower_depend_clauses (gomp_task *stmt, gimple_seq *iseq, gimple_seq *oseq) { tree c, clauses; gimple g; @@ -9969,7 +9970,7 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx) { push_gimplify_context (); dep_bind = gimple_build_bind (NULL, NULL, make_node (BLOCK)); - lower_depend_clauses (stmt, &dep_ilist, &dep_olist); + lower_depend_clauses (as_a <gomp_task *> (stmt), &dep_ilist, &dep_olist); } if (ctx->srecord_type) diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 0a076ce95f7..8688a99d8e4 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1387,15 +1387,18 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) break; case GIMPLE_OMP_TASK: - s1 = remap_gimple_seq (gimple_omp_body (stmt), id); - copy = gimple_build_omp_task - (s1, - gimple_omp_task_clauses (stmt), - gimple_omp_task_child_fn (stmt), - gimple_omp_task_data_arg (stmt), - gimple_omp_task_copy_fn (stmt), - gimple_omp_task_arg_size (stmt), - gimple_omp_task_arg_align (stmt)); + { + gomp_task *omp_task_stmt = as_a <gomp_task *> (stmt); + s1 = remap_gimple_seq (gimple_omp_body (omp_task_stmt), id); + copy = gimple_build_omp_task + (s1, + gimple_omp_task_clauses (omp_task_stmt), + gimple_omp_task_child_fn (omp_task_stmt), + gimple_omp_task_data_arg (omp_task_stmt), + gimple_omp_task_copy_fn (omp_task_stmt), + gimple_omp_task_arg_size (omp_task_stmt), + gimple_omp_task_arg_align (omp_task_stmt)); + } break; case GIMPLE_OMP_FOR: |