Blame SOURCES/gcc5-ppc32-retaddr.patch

ef53e9
2005-11-28  Jakub Jelinek  <jakub@redhat.com>
ef53e9
ef53e9
	* config/rs6000/rs6000.c (rs6000_return_addr): If COUNT == 0,
ef53e9
	read word RETURN_ADDRESS_OFFSET bytes above arg_pointer_rtx
ef53e9
	instead of doing an extran indirection from frame_pointer_rtx.
ef53e9
ef53e9
	* gcc.dg/20051128-1.c: New test.
ef53e9
ef53e9
--- gcc/config/rs6000/rs6000.c.jj	2005-11-26 14:38:01.000000000 +0100
ef53e9
+++ gcc/config/rs6000/rs6000.c	2005-11-28 20:32:18.000000000 +0100
ef53e9
@@ -20970,18 +20970,22 @@ rs6000_return_addr (int count, rtx frame
ef53e9
   if (count != 0
ef53e9
       || ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_DARWIN) && flag_pic))
ef53e9
     {
ef53e9
+      rtx x;
ef53e9
       cfun->machine->ra_needs_full_frame = 1;
ef53e9
 
ef53e9
-      return
ef53e9
-	gen_rtx_MEM
ef53e9
-	  (Pmode,
ef53e9
-	   memory_address
ef53e9
-	   (Pmode,
ef53e9
-	    plus_constant (Pmode,
ef53e9
-			   copy_to_reg
ef53e9
-			   (gen_rtx_MEM (Pmode,
ef53e9
-					 memory_address (Pmode, frame))),
ef53e9
-			   RETURN_ADDRESS_OFFSET)));
ef53e9
+      if (count == 0)
ef53e9
+	{
ef53e9
+	  gcc_assert (frame == frame_pointer_rtx);
ef53e9
+	  x = arg_pointer_rtx;
ef53e9
+	}
ef53e9
+      else
ef53e9
+	{
ef53e9
+	  x = memory_address (Pmode, frame);
ef53e9
+	  x = copy_to_reg (gen_rtx_MEM (Pmode, x));
ef53e9
+	}
ef53e9
+
ef53e9
+      x = plus_constant (Pmode, x, RETURN_ADDRESS_OFFSET);
ef53e9
+      return gen_rtx_MEM (Pmode, memory_address (Pmode, x));
ef53e9
     }
ef53e9
 
ef53e9
   cfun->machine->ra_need_lr = 1;
ef53e9
--- gcc/testsuite/gcc.dg/20051128-1.c.jj	2005-10-10 11:21:41.096999000 +0200
ef53e9
+++ gcc/testsuite/gcc.dg/20051128-1.c	2005-11-28 12:30:57.000000000 +0100
ef53e9
@@ -0,0 +1,41 @@
ef53e9
+/* { dg-do run } */
ef53e9
+/* { dg-options "-O2 -fpic" } */
ef53e9
+
ef53e9
+extern void exit (int);
ef53e9
+extern void abort (void);
ef53e9
+
ef53e9
+int b;
ef53e9
+
ef53e9
+struct A
ef53e9
+{
ef53e9
+  void *pad[147];
ef53e9
+  void *ra, *h;
ef53e9
+  long o;
ef53e9
+};
ef53e9
+
ef53e9
+void
ef53e9
+__attribute__((noinline))
ef53e9
+foo (struct A *a, void *x)
ef53e9
+{
ef53e9
+  __builtin_memset (a, 0, sizeof (a));
ef53e9
+  if (!b)
ef53e9
+    exit (0);
ef53e9
+}
ef53e9
+
ef53e9
+void
ef53e9
+__attribute__((noinline))
ef53e9
+bar (void)
ef53e9
+{
ef53e9
+  struct A a;
ef53e9
+
ef53e9
+  __builtin_unwind_init ();
ef53e9
+  foo (&a, __builtin_return_address (0));
ef53e9
+}
ef53e9
+
ef53e9
+int
ef53e9
+main (void)
ef53e9
+{
ef53e9
+  bar ();
ef53e9
+  abort ();
ef53e9
+  return 0;
ef53e9
+}