diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-09-09 17:58:59 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-09-09 17:58:59 +0000 |
commit | e8448ba5300e32917fb12f877ae40711c2b452a3 (patch) | |
tree | 4cc1aecf5c5fc575c2235d1a62a8de07c0e250ca /gcc/config | |
parent | 504279ae0a0ce28ad37f820dcdb7f6557aabef7c (diff) | |
download | gcc-e8448ba5300e32917fb12f877ae40711c2b452a3.zip gcc-e8448ba5300e32917fb12f877ae40711c2b452a3.tar.gz gcc-e8448ba5300e32917fb12f877ae40711c2b452a3.tar.bz2 |
Make note_stores take an rtx_insn
I have a series of patches that (as a side effect) makes all rtl
passes use the information collected by -fipa-ra. This showed up a
latent bug in the liveness tracking in regrename.c, which doesn't take
CALL_INSN_FUNCTION_USAGE into account when processing clobbers.
This actually seems to be quite a common problem with passes that use
note_stores; only a handful remember to walk CALL_INSN_FUNCTION_USAGE
too. I think it was just luck that I saw it with regrename first.
This patch tries to make things more robust by passing an insn rather
than a pattern to note_stores. The old function is still available
as note_pattern_stores for the few places that need it.
When updating callers, I've erred on the side of using note_stores
rather than note_pattern_stores, because IMO note_stores should be
the default choice and we should only use note_pattern_stores if
there's a specific reason. Specifically:
* For cselib.c, "body" may be a COND_EXEC_CODE instead of the main
insn pattern.
* For ira.c, I wasn't sure whether extending no_equiv to
CALL_INSN_FUNCTION_USAGE really made sense, since we don't do that
for normal call-clobbered registers. Same for mark_not_eliminable
in reload1.c
* Some other places only have a pattern available, and since those
places wouldn't benefit from walking CALL_INSN_FUNCTION_USAGE,
it seemed better to alter the code as little as possible.
* In the config/ changes, quite a few callers have already weeded
out CALL insns. It still seemed better to use note_stores rather
than prematurely optimise. (note_stores should tail call to
note_pattern_stores once it sees that the insn isn't a call.)
The patch also documents what SETs mean in CALL_INSN_FUNCTION_USAGE.
2019-09-09 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* rtl.h (CALL_INSN_FUNCTION_USAGE): Document what SETs mean.
(note_pattern_stores): Declare.
(note_stores): Take an rtx_insn *.
* rtlanal.c (set_of): Use note_pattern_stores instead of note_stores.
(find_all_hard_reg_sets): Pass the insn rather than its pattern to
note_stores. Remove explicit handling of CALL_INSN_FUNCTION_USAGE.
(note_stores): Take an rtx_insn * as argument and process
CALL_INSN_FUNCTION_USAGE. Rename old function to...
(note_pattern_stores): ...this.
(find_first_parameter_load): Pass the insn rather than
its pattern to note_stores.
* alias.c (memory_modified_in_insn_p, init_alias_analysis): Likewise.
* caller-save.c (setup_save_areas, save_call_clobbered_regs)
(insert_one_insn): Likewise.
* combine.c (combine_instructions): Likewise.
(likely_spilled_retval_p): Likewise.
(try_combine): Use note_pattern_stores instead of note_stores.
(record_dead_and_set_regs): Pass the insn rather than its pattern
to note_stores.
(reg_dead_at_p): Likewise.
* config/bfin/bfin.c (workaround_speculation): Likewise.
* config/c6x/c6x.c (maybe_clobber_cond): Likewise. Take an rtx_insn *
rather than an rtx.
* config/frv/frv.c (frv_registers_update): Use note_pattern_stores
instead of note_stores.
(frv_optimize_membar_local): Pass the insn rather than its pattern
to note_stores.
* config/gcn/gcn.c (gcn_md_reorg): Likewise.
* config/i386/i386.c (ix86_avx_u128_mode_after): Likewise.
* config/mips/mips.c (vr4130_true_reg_dependence_p): Likewise.
(r10k_needs_protection_p, mips_sim_issue_insn): Likewise.
(mips_reorg_process_insns): Likewise.
* config/s390/s390.c (s390_regs_ever_clobbered): Likewise.
* config/sh/sh.c (flow_dependent_p): Likewise. Take rtx_insn *s
rather than rtxes.
* cse.c (delete_trivially_dead_insns): Pass the insn rather than
its pattern to note_stores.
* cselib.c (cselib_record_sets): Use note_pattern_stores instead
of note_stores.
* dce.c (mark_nonreg_stores): Remove the "body" parameter and pass
the insn to note_stores.
(prescan_insns_for_dce): Update call accordingly.
* ddg.c (mem_write_insn_p): Pass the insn rather than its pattern
to note_stores.
* df-problems.c (can_move_insns_across): Likewise.
* dse.c (emit_inc_dec_insn_before, replace_read): Likewise.
* function.c (assign_parm_setup_reg): Likewise.
* gcse-common.c (record_last_mem_set_info_common): Likewise.
* gcse.c (load_killed_in_block_p, compute_hash_table_work): Likewise.
(single_set_gcse): Likewise.
* ira.c (validate_equiv_mem): Likewise.
(update_equiv_regs): Use note_pattern_stores rather than note_stores
for no_equiv.
* loop-doloop.c (doloop_optimize): Pass the insn rather than its
pattern to note_stores.
* loop-invariant.c (calculate_loop_reg_pressure): Likewise.
* loop-iv.c (simplify_using_initial_values): Likewise.
* mode-switching.c (optimize_mode_switching): Likewise.
* optabs.c (emit_libcall_block_1): Likewise.
(expand_atomic_compare_and_swap): Likewise.
* postreload-gcse.c (load_killed_in_block_p): Likewise.
(record_opr_changes): Likewise. Remove explicit handling of
CALL_INSN_FUNCTION_USAGE.
* postreload.c (reload_combine, reload_cse_move2add): Likewise.
* regcprop.c (kill_clobbered_values): Likewise.
(copyprop_hardreg_forward_1): Pass the insn rather than its pattern
to note_stores.
* regrename.c (build_def_use): Likewise.
* reload1.c (reload): Use note_pattern_stores instead of note_stores
for mark_not_eliminable.
(reload_as_needed): Pass the insn rather than its pattern
to note_stores.
(emit_output_reload_insns): Likewise.
* resource.c (mark_target_live_regs): Likewise.
* sched-deps.c (init_insn_reg_pressure_info): Likewise.
* sched-rgn.c (sets_likely_spilled): Use note_pattern_stores
instead of note_stores.
* shrink-wrap.c (try_shrink_wrapping): Pass the insn rather than
its pattern to note_stores.
* stack-ptr-mod.c (pass_stack_ptr_mod::execute): Likewise.
* var-tracking.c (adjust_insn, add_with_sets): Likewise.
From-SVN: r275527
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/bfin/bfin.c | 2 | ||||
-rw-r--r-- | gcc/config/c6x/c6x.c | 4 | ||||
-rw-r--r-- | gcc/config/frv/frv.c | 7 | ||||
-rw-r--r-- | gcc/config/gcn/gcn.c | 4 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 2 | ||||
-rw-r--r-- | gcc/config/mips/mips.c | 12 | ||||
-rw-r--r-- | gcc/config/s390/s390.c | 2 | ||||
-rw-r--r-- | gcc/config/sh/sh.c | 6 |
8 files changed, 18 insertions, 21 deletions
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 80ab777..49f18b6 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -4419,7 +4419,7 @@ workaround_speculation (void) we found earlier. */ if (recog_memoized (insn) != CODE_FOR_compare_eq) { - note_stores (PATTERN (insn), note_np_check_stores, NULL); + note_stores (insn, note_np_check_stores, NULL); if (np_check_regno != -1) { if (find_regno_note (insn, REG_INC, np_check_regno)) diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c index 8477d35..05b111e 100644 --- a/gcc/config/c6x/c6x.c +++ b/gcc/config/c6x/c6x.c @@ -4308,7 +4308,7 @@ clobber_cond_1 (rtx x, const_rtx pat ATTRIBUTE_UNUSED, void *data1) only those jumps which are still in flight. */ static void -maybe_clobber_cond (rtx insn, int clock_var) +maybe_clobber_cond (rtx_insn *insn, int clock_var) { int n, idx; idx = ss.jump_cycle_index; @@ -4333,7 +4333,7 @@ maybe_clobber_cond (rtx insn, int clock_var) continue; } - note_stores (PATTERN (insn), clobber_cond_1, ss.jump_cond + idx); + note_stores (insn, clobber_cond_1, ss.jump_cond + idx); for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) if (REG_NOTE_KIND (link) == REG_INC) clobber_cond_1 (XEXP (link, 0), NULL_RTX, ss.jump_cond + idx); diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c index c1b3c9e..6008e9a 100644 --- a/gcc/config/frv/frv.c +++ b/gcc/config/frv/frv.c @@ -7136,7 +7136,7 @@ frv_registers_update (rtx x) flags |= frv_cond_flags (XEXP (x, 0)); x = XEXP (x, 1); } - note_stores (x, frv_registers_update_1, &flags); + note_pattern_stores (x, frv_registers_update_1, &flags); } @@ -7770,8 +7770,7 @@ frv_optimize_membar_local (basic_block bb, struct frv_io *next_io, /* Invalidate NEXT_IO's address if it depends on something that is clobbered by INSN. */ if (next_io->var_address) - note_stores (PATTERN (insn), frv_io_check_address, - &next_io->var_address); + note_stores (insn, frv_io_check_address, &next_io->var_address); /* If the next membar is associated with a __builtin_read, see if INSN reads from that address. If it does, and if @@ -7814,7 +7813,7 @@ frv_optimize_membar_local (basic_block bb, struct frv_io *next_io, if (volatile_refs_p (PATTERN (insn))) CLEAR_HARD_REG_SET (used_regs); else - note_stores (PATTERN (insn), frv_io_handle_set, &used_regs); + note_stores (insn, frv_io_handle_set, &used_regs); note_uses (&PATTERN (insn), frv_io_handle_use, &used_regs); break; diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c index 8645ecc..cdb1c6e 100644 --- a/gcc/config/gcn/gcn.c +++ b/gcc/config/gcn/gcn.c @@ -4345,7 +4345,7 @@ gcn_md_reorg (void) HARD_REG_SET defs, uses; CLEAR_HARD_REG_SET (defs); CLEAR_HARD_REG_SET (uses); - note_stores (PATTERN (insn), record_hard_reg_sets, &defs); + note_stores (insn, record_hard_reg_sets, &defs); note_uses (&PATTERN (insn), record_hard_reg_uses, &uses); bool exec_lo_def_p = TEST_HARD_REG_BIT (defs, EXEC_LO_REG); @@ -4533,7 +4533,7 @@ gcn_md_reorg (void) HARD_REG_SET ireads, iwrites; CLEAR_HARD_REG_SET (ireads); CLEAR_HARD_REG_SET (iwrites); - note_stores (PATTERN (insn), record_hard_reg_sets, &iwrites); + note_stores (insn, record_hard_reg_sets, &iwrites); note_uses (&PATTERN (insn), record_hard_reg_uses, &ireads); /* Scan recent previous instructions for dependencies not handled in diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 50571a0..f6de6e9 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -13635,7 +13635,7 @@ ix86_avx_u128_mode_after (int mode, rtx_insn *insn) if (CALL_P (insn)) { bool avx_upper_reg_found = false; - note_stores (pat, ix86_check_avx_upper_stores, &avx_upper_reg_found); + note_stores (insn, ix86_check_avx_upper_stores, &avx_upper_reg_found); return avx_upper_reg_found ? AVX_U128_DIRTY : AVX_U128_CLEAN; } diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index c24dc71..c5389d2 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -14889,8 +14889,7 @@ vr4130_true_reg_dependence_p_1 (rtx x, const_rtx pat ATTRIBUTE_UNUSED, static bool vr4130_true_reg_dependence_p (rtx insn) { - note_stores (PATTERN (vr4130_last_insn), - vr4130_true_reg_dependence_p_1, &insn); + note_stores (vr4130_last_insn, vr4130_true_reg_dependence_p_1, &insn); return insn == 0; } @@ -17787,7 +17786,7 @@ r10k_needs_protection_p (rtx_insn *insn) if (mips_r10k_cache_barrier == R10K_CACHE_BARRIER_STORE) { - note_stores (PATTERN (insn), r10k_needs_protection_p_store, &insn); + note_stores (insn, r10k_needs_protection_p_store, &insn); return insn == NULL_RTX; } @@ -18296,7 +18295,7 @@ mips_sim_issue_insn (struct mips_sim *state, rtx_insn *insn) state->insns_left); mips_sim_insn = insn; - note_stores (PATTERN (insn), mips_sim_record_set, state); + note_stores (insn, mips_sim_record_set, state); } /* Simulate issuing a NOP in state STATE. */ @@ -19026,7 +19025,7 @@ mips_reorg_process_insns (void) &uses); HARD_REG_SET delay_sets; CLEAR_HARD_REG_SET (delay_sets); - note_stores (PATTERN (SEQ_END (insn)), record_hard_reg_sets, + note_stores (SEQ_END (insn), record_hard_reg_sets, &delay_sets); rtx_insn *prev = prev_active_insn (insn); @@ -19036,8 +19035,7 @@ mips_reorg_process_insns (void) { HARD_REG_SET sets; CLEAR_HARD_REG_SET (sets); - note_stores (PATTERN (prev), record_hard_reg_sets, - &sets); + note_stores (prev, record_hard_reg_sets, &sets); /* Re-order if safe. */ if (!hard_reg_set_intersect_p (delay_sets, uses) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 2478426..389fca8 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -9474,7 +9474,7 @@ s390_regs_ever_clobbered (char regs_ever_clobbered[]) continue; } - note_stores (pat, + note_stores (cur_insn, s390_reg_clobbered_rtx, regs_ever_clobbered); } diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 3b22d96..04c56aa 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -249,7 +249,7 @@ static void sh_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); static void sh_file_start (void); static bool sh_assemble_integer (rtx, unsigned int, int); -static bool flow_dependent_p (rtx, rtx); +static bool flow_dependent_p (rtx_insn *, rtx_insn *); static void flow_dependent_p_1 (rtx, const_rtx, void *); static int shiftcosts (rtx); static int and_xor_ior_costs (rtx, int); @@ -9633,11 +9633,11 @@ sh_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost, /* Check if INSN is flow-dependent on DEP_INSN. Can also be used to check if DEP_INSN is anti-flow dependent on INSN. */ static bool -flow_dependent_p (rtx insn, rtx dep_insn) +flow_dependent_p (rtx_insn *insn, rtx_insn *dep_insn) { rtx tmp = PATTERN (insn); - note_stores (PATTERN (dep_insn), flow_dependent_p_1, &tmp); + note_stores (dep_insn, flow_dependent_p_1, &tmp); return tmp == NULL_RTX; } |