https://gcc.gnu.org/g:bcaf6afe95a472a1192249448b3474a4238ed2b6
commit bcaf6afe95a472a1192249448b3474a4238ed2b6 Author: Michael Matz <[email protected]> Date: Mon Mar 5 23:20:07 2018 +0100 update-stmt: update_stmt_if_modified only check liike update_stmt does. Also tried update_stmt_fn, but that needs real rebuilding for now. make check is same as some revs ago, with seven known fails. Diff: --- gcc/cgraph.c | 8 ++++---- gcc/gimple-ssa.h | 27 ++++++++++++++++++-------- gcc/gimple.c | 3 ++- gcc/tree-ssa-operands.c | 50 +++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 65 insertions(+), 23 deletions(-) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 9a7d54d7ceed..9eafdfc8923a 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1506,7 +1506,7 @@ cgraph_edge::redirect_call_stmt_to_callee (void) { new_stmt = e->call_stmt; gimple_call_set_fndecl (new_stmt, e->callee->decl); - update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); + update_stmt_for_real_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); } /* If changing the call to __cxa_pure_virtual or similar noreturn function, @@ -1534,17 +1534,17 @@ cgraph_edge::redirect_call_stmt_to_callee (void) gimple *set_stmt = gimple_build_assign (lhs, var); gsi = gsi_for_stmt (new_stmt); gsi_insert_before_without_update (&gsi, set_stmt, GSI_SAME_STMT); - update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), set_stmt); + update_stmt_for_real_fn (DECL_STRUCT_FUNCTION (e->caller->decl), set_stmt); } gimple_call_set_lhs (new_stmt, NULL_TREE); - update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); + update_stmt_for_real_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); } /* If new callee has no static chain, remove it. */ if (gimple_call_chain (new_stmt) && !DECL_STATIC_CHAIN (e->callee->decl)) { gimple_call_set_chain (new_stmt, NULL); - update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); + update_stmt_for_real_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); } maybe_remove_unused_call_args (DECL_STRUCT_FUNCTION (e->caller->decl), diff --git a/gcc/gimple-ssa.h b/gcc/gimple-ssa.h index e4328c50474d..6cea5c3efca4 100644 --- a/gcc/gimple-ssa.h +++ b/gcc/gimple-ssa.h @@ -164,19 +164,32 @@ gimple_vdef_op (gimple *g) return NULL_DEF_OPERAND_P; } +/* Mark statement S as modified, and update it. */ +void update_stmt_fn (struct function *, gimple *); + /* Mark statement S as modified, and update it. */ static inline void -update_stmt_for_real (gimple *s) +update_stmt_for_real_fn (struct function *fn, gimple *s) { if (gimple_has_ops (s)) { gimple_set_modified (s, true); - update_stmt_operands (cfun, s); + update_stmt_operands (fn, s); } } -void update_stmt (gimple *); +static inline void +update_stmt_for_real (gimple *s) +{ + update_stmt_for_real_fn (cfun, s); +} + +static inline void +update_stmt (gimple *s) +{ + update_stmt_fn (cfun, s); +} /* Update statement S if it has been optimized. */ @@ -184,12 +197,10 @@ static inline void update_stmt_if_modified (gimple *s) { if (gimple_modified_p (s)) - update_stmt_operands (cfun, s); + update_stmt_fn (cfun, s); } -/* Mark statement S as modified, and update it. */ - -static inline void +/*static inline void update_stmt_fn (struct function *fn, gimple *s) { if (gimple_has_ops (s)) @@ -197,7 +208,7 @@ update_stmt_fn (struct function *fn, gimple *s) gimple_set_modified (s, true); update_stmt_operands (fn, s); } -} +}*/ #endif /* GCC_GIMPLE_SSA_H */ diff --git a/gcc/gimple.c b/gcc/gimple.c index ccc35adaf82a..f2e5a3af6545 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1678,6 +1678,7 @@ gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code, memcpy (new_stmt, stmt, gimple_size (gimple_code (stmt))); gimple_init_singleton (new_stmt); gimple_set_use_ops (new_stmt, NULL); + new_stmt->bb = NULL; gsi_replace (gsi, new_stmt, false); stmt = new_stmt; @@ -3124,7 +3125,7 @@ maybe_remove_unused_call_args (struct function *fn, gimple *stmt) && gimple_call_num_args (stmt)) { gimple_set_num_ops (stmt, 3); - update_stmt_fn (fn, stmt); + update_stmt_for_real_fn (fn, stmt); } } diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index 1a998268db28..26223aac13b6 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -1020,12 +1020,12 @@ update_stmt_operands (struct function *fn, gimple *stmt) } void -update_stmt (gimple *s) +update_stmt_fn (struct function *fn, gimple *s) { - if (gimple_has_ops (s) && ssa_operands_active (cfun)) + if (gimple_has_ops (s) && ssa_operands_active (fn)) { if (!flag_try_patch) - update_stmt_for_real (s); + update_stmt_for_real_fn (fn, s); else { /* Cleanup stale per-statement operands. Those happen @@ -1041,13 +1041,14 @@ update_stmt (gimple *s) else ptr = &((*ptr)->next); }*/ - if (verify_ssa_operands (s)) + if (s->bb && verify_ssa_operands (s)) { print_gimple_stmt (stderr, s, 0, TDF_VOPS); abort (); } } } + gimple_set_modified (s, false); } static use_optype_p * @@ -1118,10 +1119,39 @@ update_stmt_use (use_operand_p use) ; free_stmt_use_op (puse); - if (gimple_debug_bind_p (stmt) - && pnewval == gimple_debug_bind_get_value_ptr (stmt) - && *pnewval - && !is_gimple_min_invariant (*pnewval)) + if (is_gimple_call (stmt) && pnewval == gimple_call_fn_ptr (stmt)) + { + /* We replaced a function pointer (ssa name) with a real function + decl (address), so our VOPs might be wrong. Remove any we don't + want. + + XXX make it a bit faster, e.g. arguments are always + regtype && gimple_val || !regtype && gimple_lval, and new fn + might also have vuse/vdef */ + start_ssa_stmt_operands (); + maybe_add_call_vops (as_a <gcall *> (stmt)); + get_expr_operands (stmt, gimple_op_ptr (stmt, 0), opf_def); + for (unsigned i = 1, n = gimple_num_ops (stmt); i < n; i++) + get_expr_operands (stmt, gimple_op_ptr (stmt, i), opf_use); + + if (!(build_flags & BF_VDEF) && gimple_vdef (stmt)) + { + if (TREE_CODE (gimple_vdef (stmt)) == SSA_NAME) + { + unlink_stmt_vdef (stmt); + release_ssa_name_fn (cfun, gimple_vdef (stmt)); + } + gimple_set_vdef (stmt, NULL_TREE); + } + if (!(build_flags & BF_VUSE) && gimple_vuse (stmt)) + gimple_set_vuse (stmt, NULL_TREE); + + cleanup_build_arrays (); + } + else if (gimple_debug_bind_p (stmt) + && pnewval == gimple_debug_bind_get_value_ptr (stmt) + && *pnewval + && !is_gimple_min_invariant (*pnewval)) { start_ssa_stmt_operands (); get_expr_operands (stmt, pnewval, opf_no_vops | opf_use); @@ -1197,8 +1227,8 @@ diddle_vops (gimple *stmt, int oldvop, int newvop, unsigned nop) { /* XXX volatile really should imply VDEF always, but doesn't right now */ int stmtvop - = (gimple_has_volatile_ops (stmt) ? BF_VOLATILE : 0) - | (gimple_vdef (stmt) ? BF_VDEF | BF_VUSE + = /*(gimple_has_volatile_ops (stmt) ? BF_VOLATILE : 0) + |*/ (gimple_vdef (stmt) ? BF_VDEF | BF_VUSE : gimple_vuse (stmt) ? BF_VUSE : 0); /* ??? The following might seem like a good test:
