This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix __builtin_return_address (0) on powerpc*-ibm-aix*


On Mon, Jul 21, 2003 at 01:53:32PM -0400, David Edelsohn wrote:
> Jakub> Then, rs6000_emit_prologue could either force inline saving if this
> Jakub> flag is set, or emit code to restore lr after bl .savefp* call.
> 
> 	Forcing inline FPR saving when return_addr is called seems like
> the right solution to me.

The following patch fixes the:
void bar (void *);
void foo (void)
{
  double d0, d1, d2, d3, d4, d5;
  void *lr;
  asm volatile ("" : "=f" (d0), "=f" (d1), "=f" (d2), "=f" (d3), "=f" (d4), "=f" (d5));
  lr = __builtin_return_address (0);
  bar (lr);
  asm volatile ("" : : "f" (d0), "f" (d1), "f" (d2), "f" (d3), "f" (d4), "f" (d5));
}
testcase. Can you please test if it fixes EH?
Ok to commit if it works?

2003-07-21  Jakub Jelinek  <jakub@redhat.com>

	* config/rs6000/rs6000.h (machine_function): Add need_lr.
	* config/rs6000/rs6000.c (rs6000_return_addr): Set it.
	(rs6000_emit_prologue): Save FPRs inline if set.

--- gcc/config/rs6000/rs6000.h.jj	2003-07-15 10:00:38.000000000 -0400
+++ gcc/config/rs6000/rs6000.h	2003-07-21 13:54:27.000000000 -0400
@@ -1708,6 +1708,8 @@ typedef struct machine_function GTY(())
   const char *some_ld_name;
   /* Whether the instruction chain has been scanned already.  */
   int insn_chain_scanned_p;
+  /* Flags if __builtin_return_address (0) was used.  */
+  int need_lr;
 } machine_function;
 
 /* Define a data type for recording info about an argument list
--- gcc/config/rs6000/rs6000.c.jj	2003-07-16 07:26:25.000000000 -0400
+++ gcc/config/rs6000/rs6000.c	2003-07-21 13:56:35.000000000 -0400
@@ -10542,6 +10542,7 @@ rs6000_return_addr (count, frame)
 			   RETURN_ADDRESS_OFFSET)));
     }
 
+  cfun->machine->need_lr = 1;
   return get_hard_reg_initial_val (Pmode, LINK_REGISTER_REGNUM);
 }
 
@@ -11252,7 +11253,8 @@ rs6000_emit_prologue ()
 			      || info->spe_64bit_regs_used == 0)
 			  && info->first_gp_reg_save < 31);
   saving_FPRs_inline = (info->first_fp_reg_save == 64
-			|| FP_SAVE_INLINE (info->first_fp_reg_save));
+			|| FP_SAVE_INLINE (info->first_fp_reg_save)
+			|| cfun->machine->need_lr);
 
   /* For V.4, update stack before we do any saving and set back pointer.  */
   if (info->push_p


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]