- rtx link;
-
- /* If some registers have been saved, see if INSN references
- any of them. We must restore them before the insn if so. */
-
- if (n_regs_saved)
- restore_referenced_regs (PATTERN (insn), insn, insn_mode);
-
- /* NB: the normal procedure is to first enliven any
- registers set by insn, then deaden any registers that
- had their last use at insn. This is incorrect now,
- since multiple pseudos may have been mapped to the
- same hard reg, and the death notes are ambiguous. So
- it must be done in the other, safe, order. */
-
- for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
- if (REG_NOTE_KIND (link) == REG_DEAD)
- clear_reg_live (XEXP (link, 0));
-
- /* When we reach a call, we need to save all registers that are
- live, call-used, not fixed, and not already saved. We must
- test at this point because registers that die in a CALL_INSN
- are not live across the call and likewise for registers that
- are born in the CALL_INSN.
-
- If registers are filled with parameters for this function,
- and some of these are also being set by this function, then
- they will not appear to die (no REG_DEAD note for them),
- to check if in fact they do, collect the set registers in
- hard_regs_live first. */
-
- if (code == CALL_INSN)
- {
- HARD_REG_SET this_call_sets;
- {
- HARD_REG_SET old_hard_regs_live;
-
- /* Save the hard_regs_live information. */
- COPY_HARD_REG_SET (old_hard_regs_live, hard_regs_live);
-
- /* Now calculate hard_regs_live for this CALL_INSN
- only. */
- CLEAR_HARD_REG_SET (hard_regs_live);
- note_stores (PATTERN (insn), set_reg_live);
- COPY_HARD_REG_SET (this_call_sets, hard_regs_live);
-
- /* Restore the hard_regs_live information. */
- COPY_HARD_REG_SET (hard_regs_live, old_hard_regs_live);
- }
-
- for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
- if (call_used_regs[regno] && ! call_fixed_regs[regno]
- && TEST_HARD_REG_BIT (hard_regs_live, regno)
- /* It must not be set by this instruction. */
- && ! TEST_HARD_REG_BIT (this_call_sets, regno)
- && ! TEST_HARD_REG_BIT (hard_regs_saved, regno))
- regno += insert_save_restore (insn, 1, regno,
- insn_mode, 0);
-
- /* Put the information for this CALL_INSN on top of what
- we already had. */
- IOR_HARD_REG_SET (hard_regs_live, this_call_sets);
- COPY_HARD_REG_SET (hard_regs_need_restore, hard_regs_saved);
-
- /* Must recompute n_regs_saved. */
- n_regs_saved = 0;
- for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
- if (TEST_HARD_REG_BIT (hard_regs_saved, regno))
- n_regs_saved++;
- }