]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: rtlanal.c (get_initial_register_offset): Fall back to the estimate as long...
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 6 Apr 2019 21:44:33 +0000 (21:44 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 6 Apr 2019 21:44:33 +0000 (21:44 +0000)
Backport from mainline
2019-02-19  Eric Botcazou  <ebotcazou@adacore.com>

* rtlanal.c (get_initial_register_offset): Fall back to the estimate
as long as the epilogue isn't completed.

From-SVN: r270183

gcc/ChangeLog
gcc/rtlanal.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/opt73.adb [new file with mode: 0644]

index 7aab465db1c9cef2ec6db8f1ae30ec6f26d7b143..b32a5d734e35fd94bebbd1bbcfcd1875c7afa9cd 100644 (file)
@@ -1,3 +1,11 @@
+2019-04-06  Eric Botcazou  <ebotcazou@adacore.com>
+
+       Backport from mainline
+       2019-02-19  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * rtlanal.c (get_initial_register_offset): Fall back to the estimate
+       as long as the epilogue isn't completed.
+
 2019-04-03  Richard Biener  <rguenther@suse.de>
 
        PR lto/89896
index 5df0e5d6fdd0f64d73d01f93514c470114b8129d..5642c0d6fcf42e5136d1c97a78773ef260775036 100644 (file)
@@ -357,10 +357,10 @@ get_initial_register_offset (int from, int to)
   if (to == from)
     return 0;
 
-  /* It is not safe to call INITIAL_ELIMINATION_OFFSET
-     before the reload pass.  We need to give at least
-     an estimation for the resulting frame size.  */
-  if (! reload_completed)
+  /* It is not safe to call INITIAL_ELIMINATION_OFFSET before the epilogue
+     is completed, but we need to give at least an estimate for the stack
+     pointer based on the frame size.  */
+  if (!epilogue_completed)
     {
       offset1 = crtl->outgoing_args_size + get_frame_size ();
 #if !STACK_GROWS_DOWNWARD
index 6df23353ccf1016e921e06309eb7a68bee09f7cc..5175202bff5bb0a90fc1b19fc0a5826a2bfc6643 100644 (file)
@@ -1,3 +1,7 @@
+2019-04-06  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/opt73.adb: New test.
+
 2019-04-02  Xiong Hu Luo <luoxhu@linux.ibm.com>
 
        Backport from trunk r250477.
diff --git a/gcc/testsuite/gnat.dg/opt73.adb b/gcc/testsuite/gnat.dg/opt73.adb
new file mode 100644 (file)
index 0000000..38ab477
--- /dev/null
@@ -0,0 +1,34 @@
+-- { dg-do run }
+-- { dg-options "-O" }
+
+procedure Opt73 is
+
+   type Terminal_Set_Indexed_By_Non_Terminal is
+     array (Natural range <>, Natural  range <>) of Boolean with Pack;
+
+   type Terminal_Set_Per_Non_Terminal
+     (Last_Terminal     : Natural;
+      Last_Non_Terminal : Natural) is
+   record
+      Map : Terminal_Set_Indexed_By_Non_Terminal
+        (1 .. Last_Non_Terminal, 0 .. Last_Terminal);
+   end record;
+
+   Follow : Terminal_Set_Per_Non_Terminal (5, 4);
+   Expect : Terminal_Set_Per_Non_Terminal :=
+     (5, 4, (1 => (2 => True, others => False),
+             others => (others => False)));
+
+   procedure Get_Follow (Value : out Terminal_Set_Per_Non_Terminal) is
+   begin
+      Value.Map := (others => (others => False));
+      Value.Map (1, 2) := True;
+      Value.Map (2, 0) := Value.Map (2, 0) or Value.Map (1, 0);
+   end;
+
+begin
+   Get_Follow (Follow);
+   if Follow /= Expect then
+      raise Program_Error;
+   end if;
+end;