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