* loop-invariant.c (may_assign_reg_p): Return false for frame pointer.
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 26 Apr 2018 15:21:09 +0000 (15:21 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 26 Apr 2018 15:21:09 +0000 (15:21 +0000)
From-SVN: r259683

gcc/ChangeLog
gcc/loop-invariant.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/loop_optimization24.adb [new file with mode: 0644]

index 27e56f2..4312013 100644 (file)
@@ -1,3 +1,7 @@
+2018-04-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * loop-invariant.c (may_assign_reg_p): Return false for frame pointer.
+
 2018-04-26  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.md ("isa" attribute): Add x64_sse2.
index bd31a51..e3b2eda 100644 (file)
@@ -660,6 +660,9 @@ may_assign_reg_p (rtx x)
   return (GET_MODE (x) != VOIDmode
          && GET_MODE (x) != BLKmode
          && can_copy_p (GET_MODE (x))
+         /* Do not mess with the frame pointer adjustments that can
+            be generated e.g. by expand_builtin_setjmp_receiver.  */
+         && x != frame_pointer_rtx
          && (!REG_P (x)
              || !HARD_REGISTER_P (x)
              || REGNO_REG_CLASS (REGNO (x)) != NO_REGS));
index a4d32ec..0e03325 100644 (file)
@@ -1,3 +1,7 @@
+2018-04-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/loop_optimization24.adb: New test.
+
 2018-04-26  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/85116
diff --git a/gcc/testsuite/gnat.dg/loop_optimization24.adb b/gcc/testsuite/gnat.dg/loop_optimization24.adb
new file mode 100644 (file)
index 0000000..641d28e
--- /dev/null
@@ -0,0 +1,35 @@
+-- { dg-do run }\r
+-- { dg-options "-O" }\r
+\r
+procedure Loop_Optimization24 is\r
+\r
+   procedure Callback is\r
+   begin\r
+      raise Constraint_Error;\r
+   end;\r
+\r
+   type Thread_Name_Ptr is access constant String;\r
+   type Callback_Ptr is access procedure;\r
+\r
+   type Callback_Information is record\r
+      Name : Thread_Name_Ptr;\r
+      Proc : Callback_Ptr;\r
+   end record;\r
+      \r
+   type Callback_List is array (Positive range <>) of Callback_Information;\r
+\r
+   Cbs : Callback_List\r
+     := (1 => (Proc => Callback'access, name => new String'("Callback")),\r
+         2 => (Proc => Callback'access, name => new String'("Callback")));\r
+\r
+begin\r
+   for Index in Cbs'Range loop\r
+      begin\r
+         if Cbs(Index).proc /= null then\r
+            Cbs(Index).proc.all;\r
+         end if;\r
+      exception\r
+         when Constraint_Error => null;\r
+      end;\r
+   end loop;\r
+end;\r