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