-/* Delete line notes from one block. Save them so they can be later restored
- (in restore_line_notes). HEAD and TAIL are the boundaries of the
- block in which notes should be processed. */
-
-void
-rm_line_notes (rtx head, rtx tail)
-{
- rtx next_tail;
- rtx insn;
-
- next_tail = NEXT_INSN (tail);
- for (insn = head; insn != next_tail; insn = NEXT_INSN (insn))
- {
- rtx prev;
-
- /* Farm out notes, and maybe save them in NOTE_LIST.
- This is needed to keep the debugger from
- getting completely deranged. */
- if (NOTE_NOT_BB_P (insn))
- {
- prev = insn;
- insn = unlink_line_notes (insn, next_tail);
-
- gcc_assert (prev != tail && prev != head && insn != next_tail);
- }
- }
-}
-
-/* Save line number notes for each insn in block B. HEAD and TAIL are
- the boundaries of the block in which notes should be processed. */
-
-void
-save_line_notes (int b, rtx head, rtx tail)
-{
- rtx next_tail;
-
- /* We must use the true line number for the first insn in the block
- that was computed and saved at the start of this pass. We can't
- use the current line number, because scheduling of the previous
- block may have changed the current line number. */
-
- rtx line = line_note_head[b];
- rtx insn;
-
- next_tail = NEXT_INSN (tail);
-
- for (insn = head; insn != next_tail; insn = NEXT_INSN (insn))
- if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
- line = insn;
- else
- LINE_NOTE (insn) = line;
-}
-
-/* After a block was scheduled, insert line notes into the insns list.
- HEAD and TAIL are the boundaries of the block in which notes should
- be processed. */
-
-void
-restore_line_notes (rtx head, rtx tail)
-{
- rtx line, note, prev, new;
- int added_notes = 0;
- rtx next_tail, insn;
-
- head = head;
- next_tail = NEXT_INSN (tail);
-
- /* Determine the current line-number. We want to know the current
- line number of the first insn of the block here, in case it is
- different from the true line number that was saved earlier. If
- different, then we need a line number note before the first insn
- of this block. If it happens to be the same, then we don't want to
- emit another line number note here. */
- for (line = head; line; line = PREV_INSN (line))
- if (NOTE_P (line) && NOTE_LINE_NUMBER (line) > 0)
- break;
-
- /* Walk the insns keeping track of the current line-number and inserting
- the line-number notes as needed. */
- for (insn = head; insn != next_tail; insn = NEXT_INSN (insn))
- if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
- line = insn;
- /* This used to emit line number notes before every non-deleted note.
- However, this confuses a debugger, because line notes not separated
- by real instructions all end up at the same address. I can find no
- use for line number notes before other notes, so none are emitted. */
- else if (!NOTE_P (insn)
- && INSN_UID (insn) < old_max_uid
- && (note = LINE_NOTE (insn)) != 0
- && note != line
- && (line == 0
-#ifdef USE_MAPPED_LOCATION
- || NOTE_SOURCE_LOCATION (note) != NOTE_SOURCE_LOCATION (line)
-#else
- || NOTE_LINE_NUMBER (note) != NOTE_LINE_NUMBER (line)
- || NOTE_SOURCE_FILE (note) != NOTE_SOURCE_FILE (line)
-#endif
- ))
- {
- line = note;
- prev = PREV_INSN (insn);
- if (LINE_NOTE (note))
- {
- /* Re-use the original line-number note. */
- LINE_NOTE (note) = 0;
- PREV_INSN (note) = prev;
- NEXT_INSN (prev) = note;
- PREV_INSN (insn) = note;
- NEXT_INSN (note) = insn;
- set_block_for_insn (note, BLOCK_FOR_INSN (insn));
- }
- else
- {
- added_notes++;
- new = emit_note_after (NOTE_LINE_NUMBER (note), prev);
-#ifndef USE_MAPPED_LOCATION
- NOTE_SOURCE_FILE (new) = NOTE_SOURCE_FILE (note);
-#endif
- }
- }
- if (sched_verbose && added_notes)
- fprintf (sched_dump, ";; added %d line-number notes\n", added_notes);
-}
-
-/* After scheduling the function, delete redundant line notes from the
- insns list. */
-
-void
-rm_redundant_line_notes (void)
-{
- rtx line = 0;
- rtx insn = get_insns ();
- int active_insn = 0;
- int notes = 0;
-
- /* Walk the insns deleting redundant line-number notes. Many of these
- are already present. The remainder tend to occur at basic
- block boundaries. */
- for (insn = get_last_insn (); insn; insn = PREV_INSN (insn))
- if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
- {
- /* If there are no active insns following, INSN is redundant. */
- if (active_insn == 0)
- {
- notes++;
- SET_INSN_DELETED (insn);
- }
- /* If the line number is unchanged, LINE is redundant. */
- else if (line
-#ifdef USE_MAPPED_LOCATION
- && NOTE_SOURCE_LOCATION (line) == NOTE_SOURCE_LOCATION (insn)
-#else
- && NOTE_LINE_NUMBER (line) == NOTE_LINE_NUMBER (insn)
- && NOTE_SOURCE_FILE (line) == NOTE_SOURCE_FILE (insn)
-#endif
-)
- {
- notes++;
- SET_INSN_DELETED (line);
- line = insn;
- }
- else
- line = insn;
- active_insn = 0;
- }
- else if (!((NOTE_P (insn)
- && NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED)
- || (NONJUMP_INSN_P (insn)
- && (GET_CODE (PATTERN (insn)) == USE
- || GET_CODE (PATTERN (insn)) == CLOBBER))))
- active_insn++;
-
- if (sched_verbose && notes)
- fprintf (sched_dump, ";; deleted %d line-number notes\n", notes);
-}
-