On 09/23/2016 02:21 AM, Segher Boessenkool wrote:
A restore is supposed to restore some certain register.  Restoring it
into some other register will not work.  Don't.


2016-09-23  Segher Boessenkool  <seg...@kernel.crashing.org>

        * regrename.c (build_def_use): Invalidate chains that have a
        REG_CFA_RESTORE on some instruction.

---
 gcc/regrename.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/regrename.c b/gcc/regrename.c
index 54c7768..00a5d02 100644
--- a/gcc/regrename.c
+++ b/gcc/regrename.c
@@ -1867,6 +1867,12 @@ build_def_use (basic_block bb)
                scan_rtx (insn, &XEXP (note, 0), NO_REGS, terminate_dead,
                          OP_IN);
              }
+
+         /* Step 8: Kill the chains involving register restores.  Those
+            should restore _that_ register.  */
+         for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
+           if (REG_NOTE_KIND (note) == REG_CFA_RESTORE)
+             scan_rtx (insn, &XEXP (note, 0), NO_REGS, mark_all_read, OP_IN);
        }
       else if (DEBUG_INSN_P (insn)
               && !VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (insn)))
Seems like a good thing regardless of the shrink-wrapping changes. There's a comment about 200 lines earlier (egad) which outlines the steps. Can you please add a comment there too.

It would probably be a good idea to refactor build_def_use a bit, but I'd understand if you don't want to tackle that. I don't think that desire should block this patch.

As I've said before, I'm not sure we're getting CFA notes right, particularly on the older ports, but I don't think that should block this patch.


With the earlier comment update change this is OK.

jeff

Reply via email to