}
-/* Delete all REG_EQUAL notes of the registers INSN writes, to prevent
- bad dangling REG_EQUAL notes. */
+/* Remove all REG_EQUAL and REG_EQUIV notes referring to the registers INSN
+ writes to. */
static void
-delete_corresponding_reg_eq_notes (rtx insn)
+remove_reg_equal_equiv_notes_for_defs (rtx insn)
{
df_ref *def_rec;
+
for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++)
- {
- df_ref def = *def_rec;
- unsigned int regno = DF_REF_REGNO (def);
- /* This loop is a little tricky. We cannot just go down the
- chain because it is being modified by the actions in the
- loop. So we just get the head. We plan to drain the list
- anyway. */
- while (DF_REG_EQ_USE_CHAIN (regno))
- {
- df_ref eq_use = DF_REG_EQ_USE_CHAIN (regno);
- rtx noted_insn = DF_REF_INSN (eq_use);
- rtx note = find_reg_note (noted_insn, REG_EQUAL, NULL_RTX);
- if (!note)
- note = find_reg_note (noted_insn, REG_EQUIV, NULL_RTX);
-
- /* This assert is generally triggered when someone deletes a
- REG_EQUAL or REG_EQUIV note by hacking the list manually
- rather than calling remove_note. */
- gcc_assert (note);
- remove_note (noted_insn, note);
- }
- }
+ remove_reg_equal_equiv_notes_for_regno (DF_REF_REGNO (*def_rec));
}
if (dump_file)
fprintf (dump_file, "DCE: Deleting insn %d\n", INSN_UID (insn));
- /* Before we delete the insn we have to delete REG_EQUAL notes
+ /* Before we delete the insn we have to remove the REG_EQUAL notes
for the destination regs in order to avoid dangling notes. */
- delete_corresponding_reg_eq_notes (insn);
+ remove_reg_equal_equiv_notes_for_defs (insn);
/* If a pure or const call is deleted, this may make the cfg
have unreachable blocks. We rememeber this and call
bitmap_copy (local_live, DF_WORD_LR_OUT (bb));
FOR_BB_INSNS_REVERSE (bb, insn)
- if (INSN_P (insn))
+ if (NONDEBUG_INSN_P (insn))
{
bool any_changed;
/* No matter if the instruction is needed or not, we remove
void
run_word_dce (void)
{
+ int old_flags;
+
+ if (!flag_dce)
+ return;
+
timevar_push (TV_DCE);
+ old_flags = df_clear_flags (DF_DEFER_INSN_RESCAN + DF_NO_INSN_RESCAN);
df_word_lr_add_problem ();
init_dce (true);
fast_dce (true);
fini_dce (true);
+ df_set_flags (old_flags);
timevar_pop (TV_DCE);
}