gcc/ * cgraph.h (cgraph_edge::call_stmt): Strengthen field from plain gimple to a gimple_call. (cgraph_create_edge): Require a gimple_call rather than a plain gimple. (cgraph_create_indirect_edge): Likewise. (cgraph_set_call_stmt): Likewise. (cgraph_clone_edge): Likewise. (cgraph_set_call_stmt_including_clones): Likewise. (cgraph_create_edge_including_clones): Likewise.
* cgraph.c (cgraph_set_call_stmt): Require a gimple_call rather than a plain gimple. (cgraph_create_edge_1): Likewise. (cgraph_create_edge): Likewise. (cgraph_create_indirect_edge): Likewise. (cgraph_redirect_edge_call_stmt_to_callee): Strengthen decl of "new_stmt" from gimple to gimple_call. (cgraph_update_edges_for_call_stmt_node): Add checked casts to gimple_call. * cgraphbuild.c (build_cgraph_edges): Replace is_gimple_call with dyn_cast_gimple_call and new local "call_stmt". (rebuild_cgraph_edges): Likewise. * cgraphclones.c (cgraph_clone_edge): Require a gimple_call rather than a plain gimple. (cgraph_set_call_stmt_including_clones): Likewise. (cgraph_create_edge_including_clones): Likewise. * lto-streamer-in.c (fixup_call_stmt_edges_1): Add checked casts to gimple_call. * omp-low.c (simd_clone_adjust): Strengthen local "call" from gimple to gimple_call. * trans-mem.c (ipa_tm_insert_irr_call): Likewise for "g". (ipa_tm_insert_gettmclone_call): Likewise; also strengthen "g2" to gimple_assign. * tree-emutls.c (gen_emutls_addr): Strengthen local "x" from gimple to gimple_call. * tree-inline.c (copy_bb): Replace is_gimple_call with dyn_cast_gimple_call and new local "call_stmt". * value-prof.c (gimple_ic): Require and return a gimple_call, rather than a plain gimple. * value-prof.h (gimple_ic): Likewise. Conflicts: gcc/cgraph.c --- gcc/cgraph.c | 18 ++++++++++-------- gcc/cgraph.h | 17 ++++++++++------- gcc/cgraphbuild.c | 24 ++++++++++++------------ gcc/cgraphclones.c | 6 +++--- gcc/lto-streamer-in.c | 4 ++-- gcc/omp-low.c | 2 +- gcc/trans-mem.c | 5 +++-- gcc/tree-emutls.c | 2 +- gcc/tree-inline.c | 15 ++++++++------- gcc/value-prof.c | 8 ++++---- gcc/value-prof.h | 3 ++- 11 files changed, 56 insertions(+), 48 deletions(-) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 3652796..a98b716 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -787,7 +787,7 @@ cgraph_edge (struct cgraph_node *node, gimple call_stmt) edge, then update all components. */ void -cgraph_set_call_stmt (struct cgraph_edge *e, gimple new_stmt, +cgraph_set_call_stmt (struct cgraph_edge *e, gimple_call new_stmt, bool update_speculative) { tree decl; @@ -840,7 +840,7 @@ cgraph_set_call_stmt (struct cgraph_edge *e, gimple new_stmt, static struct cgraph_edge * cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee, - gimple call_stmt, gcov_type count, int freq, + gimple_call call_stmt, gcov_type count, int freq, bool indir_unknown_callee) { struct cgraph_edge *edge; @@ -912,7 +912,7 @@ cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee, struct cgraph_edge * cgraph_create_edge (struct cgraph_node *caller, struct cgraph_node *callee, - gimple call_stmt, gcov_type count, int freq) + gimple_call call_stmt, gcov_type count, int freq) { struct cgraph_edge *edge = cgraph_create_edge_1 (caller, callee, call_stmt, count, freq, false); @@ -948,7 +948,7 @@ cgraph_allocate_init_indirect_info (void) PARAM_INDEX. */ struct cgraph_edge * -cgraph_create_indirect_edge (struct cgraph_node *caller, gimple call_stmt, +cgraph_create_indirect_edge (struct cgraph_node *caller, gimple_call call_stmt, int ecf_flags, gcov_type count, int freq) { @@ -1341,7 +1341,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e) if (e->speculative) { struct cgraph_edge *e2; - gimple new_stmt; + gimple_call new_stmt; struct ipa_ref *ref; cgraph_speculative_call_info (e, e, e2, ref); @@ -1547,7 +1547,7 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node, if (callee->decl == new_call || callee->former_clone_of == new_call) { - cgraph_set_call_stmt (e, new_stmt); + cgraph_set_call_stmt (e, new_stmt->as_a_gimple_call ()); return; } callee = callee->clone_of; @@ -1576,13 +1576,15 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node, if (new_call) { ne = cgraph_create_edge (node, cgraph_get_create_node (new_call), - new_stmt, count, frequency); + new_stmt->as_a_gimple_call (), count, + frequency); gcc_assert (ne->inline_failed); } } /* We only updated the call stmt; update pointer in cgraph edge.. */ else if (old_stmt != new_stmt) - cgraph_set_call_stmt (cgraph_edge (node, old_stmt), new_stmt); + cgraph_set_call_stmt (cgraph_edge (node, old_stmt), + new_stmt->as_a_gimple_call ()); } /* Update or remove the corresponding cgraph edge if a GIMPLE_CALL diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 59d9ce6..93e1302 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -579,7 +579,7 @@ struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgrap struct cgraph_edge *next_caller; struct cgraph_edge *prev_callee; struct cgraph_edge *next_callee; - gimple call_stmt; + gimple_call call_stmt; /* Additional information about an indirect call. Not cleared when an edge becomes direct. */ struct cgraph_indirect_call_info *indirect_info; @@ -764,8 +764,9 @@ void release_function_body (tree); void cgraph_node_remove_callees (struct cgraph_node *node); struct cgraph_edge *cgraph_create_edge (struct cgraph_node *, struct cgraph_node *, - gimple, gcov_type, int); -struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple, + gimple_call, gcov_type, int); +struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, + gimple_call, int, gcov_type, int); struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void); struct cgraph_node * cgraph_create_node (tree); @@ -776,7 +777,8 @@ struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, H HOST_WIDE_INT, tree, tree); struct cgraph_node *cgraph_node_for_asm (tree); struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple); -void cgraph_set_call_stmt (struct cgraph_edge *, gimple, bool update_speculative = true); +void cgraph_set_call_stmt (struct cgraph_edge *, gimple_call, + bool update_speculative = true); void cgraph_update_edges_for_call_stmt (gimple, tree, gimple); struct cgraph_local_info *cgraph_local_info (tree); struct cgraph_global_info *cgraph_global_info (tree); @@ -886,7 +888,7 @@ bool expand_thunk (struct cgraph_node *, bool); /* In cgraphclones.c */ struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, - struct cgraph_node *, gimple, + struct cgraph_node *, gimple_call, unsigned, gcov_type, int, bool); struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type, int, bool, vec<cgraph_edge_p>, @@ -899,11 +901,12 @@ struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node, const char *clone_name); struct cgraph_node *cgraph_find_replacement_node (struct cgraph_node *); bool cgraph_remove_node_and_inline_clones (struct cgraph_node *, struct cgraph_node *); -void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple, +void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, + gimple_call, bool update_speculative = true); void cgraph_create_edge_including_clones (struct cgraph_node *, struct cgraph_node *, - gimple, gimple, gcov_type, int, + gimple, gimple_call, gcov_type, int, cgraph_inline_failed_t); void cgraph_materialize_all_clones (void); struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *, diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c index 411214a..49f52e2 100644 --- a/gcc/cgraphbuild.c +++ b/gcc/cgraphbuild.c @@ -327,19 +327,19 @@ build_cgraph_edges (void) if (is_gimple_debug (stmt)) continue; - if (is_gimple_call (stmt)) + if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ()) { int freq = compute_call_stmt_bb_frequency (current_function_decl, bb); - decl = gimple_call_fndecl (stmt); + decl = gimple_call_fndecl (call_stmt); if (decl) cgraph_create_edge (node, cgraph_get_create_node (decl), - stmt, bb->count, freq); - else if (gimple_call_internal_p (stmt)) + call_stmt, bb->count, freq); + else if (gimple_call_internal_p (call_stmt)) ; else - cgraph_create_indirect_edge (node, stmt, - gimple_call_flags (stmt), + cgraph_create_indirect_edge (node, call_stmt, + gimple_call_flags (call_stmt), bb->count, freq); } ipa_record_stmt_references (node, stmt); @@ -459,19 +459,19 @@ rebuild_cgraph_edges (void) gimple stmt = gsi_stmt (gsi); tree decl; - if (is_gimple_call (stmt)) + if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ()) { int freq = compute_call_stmt_bb_frequency (current_function_decl, bb); - decl = gimple_call_fndecl (stmt); + decl = gimple_call_fndecl (call_stmt); if (decl) - cgraph_create_edge (node, cgraph_get_create_node (decl), stmt, + cgraph_create_edge (node, cgraph_get_create_node (decl), call_stmt, bb->count, freq); - else if (gimple_call_internal_p (stmt)) + else if (gimple_call_internal_p (call_stmt)) ; else - cgraph_create_indirect_edge (node, stmt, - gimple_call_flags (stmt), + cgraph_create_indirect_edge (node, call_stmt, + gimple_call_flags (call_stmt), bb->count, freq); } ipa_record_stmt_references (node, stmt); diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index b2eb8ab..ab761e9 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -105,7 +105,7 @@ along with GCC; see the file COPYING3. If not see /* Create clone of E in the node N represented by CALL_EXPR the callgraph. */ struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n, - gimple call_stmt, unsigned stmt_uid, gcov_type count_scale, + gimple_call call_stmt, unsigned stmt_uid, gcov_type count_scale, int freq_scale, bool update_original) { struct cgraph_edge *new_edge; @@ -611,7 +611,7 @@ cgraph_find_replacement_node (struct cgraph_node *node) void cgraph_set_call_stmt_including_clones (struct cgraph_node *orig, - gimple old_stmt, gimple new_stmt, + gimple old_stmt, gimple_call new_stmt, bool update_speculative) { struct cgraph_node *node; @@ -668,7 +668,7 @@ void cgraph_create_edge_including_clones (struct cgraph_node *orig, struct cgraph_node *callee, gimple old_stmt, - gimple stmt, gcov_type count, + gimple_call stmt, gcov_type count, int freq, cgraph_inline_failed_t reason) { diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 3238ab8..455a8cb 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -782,7 +782,7 @@ fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple *stmts, { if (gimple_stmt_max_uid (fn) < cedge->lto_stmt_uid) fatal_error ("Cgraph edge statement index out of range"); - cedge->call_stmt = stmts[cedge->lto_stmt_uid - 1]; + cedge->call_stmt = stmts[cedge->lto_stmt_uid - 1]->as_a_gimple_call (); if (!cedge->call_stmt) fatal_error ("Cgraph edge statement index not found"); } @@ -790,7 +790,7 @@ fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple *stmts, { if (gimple_stmt_max_uid (fn) < cedge->lto_stmt_uid) fatal_error ("Cgraph edge statement index out of range"); - cedge->call_stmt = stmts[cedge->lto_stmt_uid - 1]; + cedge->call_stmt = stmts[cedge->lto_stmt_uid - 1]->as_a_gimple_call (); if (!cedge->call_stmt) fatal_error ("Cgraph edge statement index not found"); } diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 396ddb0..c978c56 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -11622,7 +11622,7 @@ simd_clone_adjust (struct cgraph_node *node) tree fn = builtin_decl_explicit (BUILT_IN_ASSUME_ALIGNED); gimple_seq seq = NULL; bool need_cvt = false; - gimple call + gimple_call call = gimple_build_call (fn, 2, def, size_int (alignment)); g = call; if (!useless_type_conversion_p (TREE_TYPE (orig_arg), diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index 62d9b78..f3b9a8d 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -4990,7 +4990,7 @@ ipa_tm_insert_irr_call (struct cgraph_node *node, struct tm_region *region, basic_block bb) { gimple_stmt_iterator gsi; - gimple g; + gimple_call g; transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE); @@ -5017,7 +5017,8 @@ ipa_tm_insert_gettmclone_call (struct cgraph_node *node, gimple_stmt_iterator *gsi, gimple stmt) { tree gettm_fn, ret, old_fn, callfn; - gimple g, g2; + gimple_call g; + gimple_assign g2; bool safe; old_fn = gimple_call_fn (stmt); diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c index 3391cc3..993eaf7 100644 --- a/gcc/tree-emutls.c +++ b/gcc/tree-emutls.c @@ -437,7 +437,7 @@ gen_emutls_addr (tree decl, struct lower_emutls_data *d) { varpool_node *cvar; tree cdecl; - gimple x; + gimple_call x; cvar = control_vars[index]; cdecl = cvar->decl; diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index cdc2ff2..37d6a8b 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1764,7 +1764,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, /* We're duplicating a CALL_EXPR. Find any corresponding callgraph edges and update or duplicate them. */ - if (is_gimple_call (stmt)) + if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ()) { struct cgraph_edge *edge; @@ -1777,7 +1777,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, int edge_freq = edge->frequency; int new_freq; struct cgraph_edge *old_edge = edge; - edge = cgraph_clone_edge (edge, id->dst_node, stmt, + edge = cgraph_clone_edge (edge, id->dst_node, call_stmt, gimple_uid (stmt), REG_BR_PROB_BASE, CGRAPH_FREQ_BASE, true); @@ -1796,7 +1796,8 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, gcc_assert (!edge->indirect_unknown_callee); cgraph_speculative_call_info (old_edge, direct, indirect, ref); - indirect = cgraph_clone_edge (indirect, id->dst_node, stmt, + indirect = cgraph_clone_edge (indirect, id->dst_node, + call_stmt, gimple_uid (stmt), REG_BR_PROB_BASE, CGRAPH_FREQ_BASE, true); @@ -1835,14 +1836,14 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, case CB_CGE_MOVE_CLONES: cgraph_set_call_stmt_including_clones (id->dst_node, - orig_stmt, stmt); + orig_stmt, call_stmt); edge = cgraph_edge (id->dst_node, stmt); break; case CB_CGE_MOVE: edge = cgraph_edge (id->dst_node, orig_stmt); if (edge) - cgraph_set_call_stmt (edge, stmt); + cgraph_set_call_stmt (edge, call_stmt); break; default: @@ -1871,12 +1872,12 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, || !id->dst_node->definition); if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES) cgraph_create_edge_including_clones - (id->dst_node, dest, orig_stmt, stmt, bb->count, + (id->dst_node, dest, orig_stmt, call_stmt, bb->count, compute_call_stmt_bb_frequency (id->dst_node->decl, copy_basic_block), CIF_ORIGINALLY_INDIRECT_CALL); else - cgraph_create_edge (id->dst_node, dest, stmt, + cgraph_create_edge (id->dst_node, dest, call_stmt, bb->count, compute_call_stmt_bb_frequency (id->dst_node->decl, diff --git a/gcc/value-prof.c b/gcc/value-prof.c index 055d221..d5a30b8 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -1320,11 +1320,11 @@ check_ic_target (gimple_call call_stmt, struct cgraph_node *target) old call */ -gimple -gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call, +gimple_call +gimple_ic (gimple_call icall_stmt, struct cgraph_node *direct_call, int prob, gcov_type count, gcov_type all) { - gimple dcall_stmt; + gimple_call dcall_stmt; gimple_assign load_stmt; gimple_cond cond_stmt; tree tmp0, tmp1, tmp; @@ -1357,7 +1357,7 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call, gimple_set_vdef (icall_stmt, NULL_TREE); gimple_set_vuse (icall_stmt, NULL_TREE); update_stmt (icall_stmt); - dcall_stmt = gimple_copy (icall_stmt); + dcall_stmt = gimple_copy (icall_stmt)->as_a_gimple_call (); gimple_call_set_fndecl (dcall_stmt, direct_call->decl); dflags = flags_from_decl_or_type (direct_call->decl); if ((dflags & ECF_NORETURN) != 0) diff --git a/gcc/value-prof.h b/gcc/value-prof.h index 9d2c351..9324add 100644 --- a/gcc/value-prof.h +++ b/gcc/value-prof.h @@ -88,7 +88,8 @@ void gimple_move_stmt_histograms (struct function *, gimple, gimple); void verify_histograms (void); void free_histograms (void); void stringop_block_profile (gimple, unsigned int *, HOST_WIDE_INT *); -gimple gimple_ic (gimple, struct cgraph_node *, int, gcov_type, gcov_type); +gimple_call gimple_ic (gimple_call, struct cgraph_node *, int, gcov_type, + gcov_type); /* In tree-profile.c. */ -- 1.8.5.3