static bool deletable_insn_p (rtx_insn *insn, bool fast, bitmap arg_stores) { rtx body, x; int i; df_ref def; if (CALL_P (insn) /* We cannot delete calls inside of the recursive dce because this may cause basic blocks to be deleted and this messes up the rest of the stack of optimization passes. */ && (!df_in_progress) /* We cannot delete pure or const sibling calls because it is hard to see the result. */ && (!SIBLING_CALL_P (insn)) /* We can delete dead const or pure calls as long as they do not infinite loop. */ && (RTL_CONST_OR_PURE_CALL_P (insn) && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn))) return find_call_stack_args (as_a <rtx_call_insn *> (insn), false, fast, arg_stores); /* Don't delete jumps, notes and the like. */ if (!NONJUMP_INSN_P (insn)) return false; /* Don't delete insns that may throw if we cannot do so. */ if (!(cfun->can_delete_dead_exceptions && can_alter_cfg) && !insn_nothrow_p (insn)) return false; /* If INSN sets a global_reg, leave it untouched. */ FOR_EACH_INSN_DEF (def, insn) if (HARD_REGISTER_NUM_P (DF_REF_REGNO (def)) && global_regs[DF_REF_REGNO (def)]) return false; /* Initialization of pseudo PIC register should never be removed. */ else if (DF_REF_REG (def) == pic_offset_table_rtx && REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER) return false; body = PATTERN (insn); switch (GET_CODE (body)) { case USE: case VAR_LOCATION: return false; case CLOBBER: if (fast) { /* A CLOBBER of a dead pseudo register serves no purpose. That is not necessarily true for hard registers until after reload. */ x = XEXP (body, 0); return REG_P (x) && (!HARD_REGISTER_P (x) || reload_completed); } else /* Because of the way that use-def chains are built, it is not possible to tell if the clobber is dead because it can never be the target of a use-def chain. */ return false; case PARALLEL: for (i = XVECLEN (body, 0) - 1; i >= 0; i--) if (!deletable_insn_p_1 (XVECEXP (body, 0, i))) return false; return true; default: return deletable_insn_p_1 (body); } }
static void force_move_args_size_note (basic_block bb, rtx prev, rtx insn) { rtx note, test, next_candidate, prev_candidate; /* If PREV exists, tail-call to the logic in the other function. */ if (prev) { maybe_move_args_size_note (prev, insn, false); return; } /* First, make sure there's anything that needs doing. */ note = find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX); if (note == NULL) return; /* We need to find a spot between the previous and next exception points where we can place the note and "properly" deallocate the arguments. */ next_candidate = prev_candidate = NULL; /* It is often the case that we have insns in the order: call add sp (previous deallocation) sub sp (align for next arglist) push arg and the add/sub cancel. Therefore we begin by searching forward. */ test = insn; while ((test = next_active_insn_bb (bb, test)) != NULL) { /* Found an existing note: nothing to do. */ if (find_reg_note (test, REG_ARGS_SIZE, NULL_RTX)) return; /* Found something that affects unwinding. Stop searching. */ if (CALL_P (test) || !insn_nothrow_p (test)) break; if (next_candidate == NULL) next_candidate = test; } test = insn; while ((test = prev_active_insn_bb (bb, test)) != NULL) { rtx tnote; /* Found a place that seems logical to adjust the stack. */ tnote = find_reg_note (test, REG_ARGS_SIZE, NULL_RTX); if (tnote) { XEXP (tnote, 0) = XEXP (note, 0); return; } if (prev_candidate == NULL) prev_candidate = test; /* Found something that affects unwinding. Stop searching. */ if (CALL_P (test) || !insn_nothrow_p (test)) break; } if (prev_candidate) test = prev_candidate; else if (next_candidate) test = next_candidate; else { /* ??? We *must* have a place, lest we ICE on the lost adjustment. Options are: dummy clobber insn, nop, or prevent the removal of the sp += 0 insn. */ /* TODO: Find another way to indicate to the dwarf2 code that we have not in fact lost an adjustment. */ test = emit_insn_before (gen_rtx_CLOBBER (VOIDmode, const0_rtx), insn); } add_reg_note (test, REG_ARGS_SIZE, XEXP (note, 0)); }