]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/48542 (unchanged variables in code which calls setjmp may...
authorHans-Peter Nilsson <hp@axis.com>
Fri, 17 Jun 2011 11:24:55 +0000 (11:24 +0000)
committerHans-Peter Nilsson <hp@gcc.gnu.org>
Fri, 17 Jun 2011 11:24:55 +0000 (11:24 +0000)
PR rtl-optimization/48542
* reload.c (find_equiv_reg): Stop looking when finding a
setjmp-type call.
* reload1.c (reload_as_needed): Invalidate all reload
registers when crossing a setjmp-type call.

From-SVN: r175146

gcc/ChangeLog
gcc/reload.c
gcc/reload1.c

index 27eb7e8df3e96d9fd31c4914714204b8db3da256..eb0f7f9b8cc5a85290b8b367699c4a28629884cc 100644 (file)
@@ -1,3 +1,14 @@
+2011-06-17  Hans-Peter Nilsson  <hp@axis.com>
+
+       Backport from mainline
+       2011-06-17  Hans-Peter Nilsson  <hp@axis.com>
+
+       PR rtl-optimization/48542
+       * reload.c (find_equiv_reg): Stop looking when finding a
+       setjmp-type call.
+       * reload1.c (reload_as_needed): Invalidate all reload
+       registers when crossing a setjmp-type call.
+
 2011-06-05  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        Backport from mainline
index 5e33ff4b8430cef6d73f857bde6eb836ef0f5940..cfe6be8c5643e9f34c6ca6023f9b7947c5471eb3 100644 (file)
@@ -6716,6 +6716,15 @@ find_equiv_reg (rtx goal, rtx insn, enum reg_class class, int other,
          || num > PARAM_VALUE (PARAM_MAX_RELOAD_SEARCH_INSNS))
        return 0;
 
+      /* Don't reuse register contents from before a setjmp-type
+        function call; on the second return (from the longjmp) it
+        might have been clobbered by a later reuse.  It doesn't
+        seem worthwhile to actually go and see if it is actually
+        reused even if that information would be readily available;
+        just don't reuse it across the setjmp call.  */
+      if (CALL_P (p) && find_reg_note (p, REG_SETJMP, NULL_RTX))
+       return 0;
+
       if (NONJUMP_INSN_P (p)
          /* If we don't want spill regs ...  */
          && (! (reload_reg_p != 0
index d0fec9b29af9355fdc2a3b22c25aeb0f5430c080..8e6dbbc61a51bbe683146a29687ac3166aa1d560 100644 (file)
@@ -4311,6 +4311,13 @@ reload_as_needed (int live_known)
        {
        AND_COMPL_HARD_REG_SET (reg_reloaded_valid, call_used_reg_set);
        AND_COMPL_HARD_REG_SET (reg_reloaded_valid, reg_reloaded_call_part_clobbered);
+
+         /* If this is a call to a setjmp-type function, we must not
+            reuse any reload reg contents across the call; that will
+            just be clobbered by other uses of the register in later
+            code, before the longjmp.  */
+         if (find_reg_note (insn, REG_SETJMP, NULL_RTX))
+           CLEAR_HARD_REG_SET (reg_reloaded_valid);
        }
     }