Avoid putting a REG_NOTE on anything other than an INSN in haifa-sched.c
authorAndrew Pinski <apinski@marvell.com>
Fri, 6 Mar 2020 15:34:01 +0000 (08:34 -0700)
committerJeff Law <law@redhat.com>
Fri, 6 Mar 2020 15:35:18 +0000 (08:35 -0700)
PR rtl-optimization/93996
* haifa-sched.c (remove_notes): Be more careful when adding
REG_SAVE_NOTE.

gcc/ChangeLog
gcc/haifa-sched.c

index 843648314ae7310229bcd34a06eb01d54b7ca945..e38af8ed62069d4f142b6585ac3371bf3f637961 100644 (file)
@@ -1,3 +1,10 @@
+2020-03-06  Andrew Pinski  <apinski@marvell.com>
+           Jeff Law  <law@redhat.com>
+
+       PR rtl-optimization/93996
+       * haifa-sched.c (remove_notes): Be more careful when adding
+       REG_SAVE_NOTE.
+
 2020-03-06  Delia Burduv  <delia.burduv@arm.com>
 
        * config/arm/arm_neon.h (vld2_bf16): New.
index 1d3de7b6a762f33bec4c28127970c31e9d7a7a5b..80687fb5359ec4f27645c4f535c4e47e16c3414c 100644 (file)
@@ -4239,6 +4239,15 @@ remove_notes (rtx_insn *head, rtx_insn *tail)
          if (insn != tail)
            {
              remove_insn (insn);
+             /* If an insn was split just before the EPILOGUE_BEG note and
+                that split created new basic blocks, we could have a
+                BASIC_BLOCK note here.  Safely advance over it in that case
+                and assert that we land on a real insn.  */
+             if (NOTE_P (next)
+                 && NOTE_KIND (next) == NOTE_INSN_BASIC_BLOCK
+                 && next != next_tail)
+               next = NEXT_INSN (next);
+             gcc_assert (INSN_P (next));
              add_reg_note (next, REG_SAVE_NOTE,
                            GEN_INT (NOTE_INSN_EPILOGUE_BEG));
              break;