Blame SOURCES/gcc48-ppc32-retaddr.patch

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