Fix PR middle end/18718, REG_SAVE_NOTE related segfault

Steven Bosscher stevenb@suse.de
Fri Dec 3 11:41:00 GMT 2004


Alan Modra wrote:
>	PR middle end/18718
>	* sched-rgn.c (schedule_region): Don't assume REG_SAVE_NOTEs are
>	in pairs.

<See http://gcc.gnu.org/ml/gcc-patches/2004-11/msg02654.html>

This fixes fallout from my earlier patch to sched_analyze to not save
NOTE_INSN_EH_REGION notes (which cannot exist until after sched2), see
http://gcc.gnu.org/ml/gcc-patches/2004-11/msg01357.html.

The result of my patch is that REG_SAVE_NOTE do not appear in pairs
anymore there.  They used to appear in pairs, always.  After my patch this is no longer the case, but apparently I overlooked the places in
sched-reg.c (addressed by Alan's patch) and sched-ebb.c (which I just
noticed) where we still expect REG_SAVE_NOTEs to appear in pairs.

Alan's patch looks obviously OK to me, but I can't approve it.  As I
mentioned, the same problem also exists in sched-ebb.c:526-532:

      for (note = REG_NOTES (head); note; note = XEXP (note, 1))
        if (REG_NOTE_KIND (note) == REG_SAVE_NOTE)
          {
            remove_note (head, note);
            note = XEXP (note, 1);
            remove_note (head, note);
          }

This should now be:

      for (note = REG_NOTES (head); note; note = XEXP (note, 1))
        if (REG_NOTE_KIND (note) == REG_SAVE_NOTE)
          remove_note (head, note);

I grepped in the tree and found no other places where this same bug
could still secretly be lurking.

Gr.
Steven




More information about the Gcc-patches mailing list