From 88636fce5a0da89f812e358241d1c7c06a03589a Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 26 Apr 2018 15:21:09 +0000 Subject: [PATCH] * loop-invariant.c (may_assign_reg_p): Return false for frame pointer. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@259683 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 4 +++ gcc/loop-invariant.c | 3 +++ gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/gnat.dg/loop_optimization24.adb | 35 +++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 gcc/testsuite/gnat.dg/loop_optimization24.adb diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 27e56f233e4..431201358a3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2018-04-26 Eric Botcazou + + * loop-invariant.c (may_assign_reg_p): Return false for frame pointer. + 2018-04-26 Uros Bizjak * config/i386/i386.md ("isa" attribute): Add x64_sse2. diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index bd31a51c1d5..e3b2eda1695 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4d32ec2574..0e0332513ef 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-04-26 Eric Botcazou + + * gnat.dg/loop_optimization24.adb: New test. + 2018-04-26 Richard Biener 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 index 00000000000..641d28ed97c --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization24.adb @@ -0,0 +1,35 @@ +-- { dg-do run } +-- { dg-options "-O" } + +procedure Loop_Optimization24 is + + procedure Callback is + begin + raise Constraint_Error; + end; + + type Thread_Name_Ptr is access constant String; + type Callback_Ptr is access procedure; + + type Callback_Information is record + Name : Thread_Name_Ptr; + Proc : Callback_Ptr; + end record; + + type Callback_List is array (Positive range <>) of Callback_Information; + + Cbs : Callback_List + := (1 => (Proc => Callback'access, name => new String'("Callback")), + 2 => (Proc => Callback'access, name => new String'("Callback"))); + +begin + for Index in Cbs'Range loop + begin + if Cbs(Index).proc /= null then + Cbs(Index).proc.all; + end if; + exception + when Constraint_Error => null; + end; + end loop; +end; -- 2.11.4.GIT