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]

PATCH: Fix return_addr_rtx on PA


Currently, return_addr_rtx on the PA tries to extract the saved return
pointer register from the frame.  However, this fails when the return
pointer isn't saved to the frame.  This patch change return_addr_rtx
to use get_hard_reg_initial_val to get the initial value of the
return pointer.

Bootstrap checked on hppa1.1-hp-hpux10.20 with no regressions.

OK?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-09-14  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* pa.c (return_addr_rtx): Return NULL_RTX if count is not zero.  Use
	initial value of return pointer register instead of value in frame-20.
	Revise comments.

--- pa.c.orig	Sat Sep  8 15:21:09 2001
+++ pa.c	Thu Sep 13 15:53:15 2001
@@ -3461,7 +3462,10 @@
    the current frame, after the prologue.  FRAMEADDR is the
    frame pointer of the COUNT frame.
 
-   We want to ignore any export stub remnants here.
+   We want to ignore any export stub remnants here.  To handle this,
+   we examine the code at the return address, and if it is an export
+   stub, we return a memory rtx for the stub return address stored
+   at frame-24.
 
    The value returned is used in two different ways:
 
@@ -3476,42 +3480,36 @@
 
    This function handles most instances of case 2; however, it will
    fail if we did not originally have stub code on the return path
-   but will need code on the new return path.  This can happen if
+   but will need stub code on the new return path.  This can happen if
    the caller & callee are both in the main program, but the new
-   return location is in a shared library.
-
-   To handle this correctly we need to set the return pointer at
-   frame-20 to point to a return stub frame-24 to point to the
-   location we wish to return to.  */
+   return location is in a shared library.  */
 
 rtx
 return_addr_rtx (count, frameaddr)
-     int count ATTRIBUTE_UNUSED;
+     int count;
      rtx frameaddr;
 {
   rtx label;
+  rtx rp;
   rtx saved_rp;
   rtx ins;
 
-  if (TARGET_64BIT)
-    return gen_rtx_MEM (Pmode, plus_constant (frameaddr, -16));
+  if (count != 0)
+    return NULL_RTX;
 
-  if (TARGET_NO_SPACE_REGS)
-    return gen_rtx_MEM (Pmode, plus_constant (frameaddr, -20));
+  rp = get_hard_reg_initial_val (Pmode, 2);
 
-  /* First, we start off with the normal return address pointer from
-     -20[frameaddr].  */
+  if (TARGET_64BIT || TARGET_NO_SPACE_REGS)
+    return rp;
 
   saved_rp = gen_reg_rtx (Pmode);
-  emit_move_insn (saved_rp, plus_constant (frameaddr, -20));
+  emit_move_insn (saved_rp, rp);
 
   /* Get pointer to the instruction stream.  We have to mask out the
      privilege level from the two low order bits of the return address
      pointer here so that ins will point to the start of the first
      instruction that would have been executed if we returned.  */
-  ins = copy_to_reg (gen_rtx_AND (Pmode,
-				  copy_to_reg (gen_rtx_MEM (Pmode, saved_rp)),
-				  MASK_RETURN_ADDR));
+  ins = copy_to_reg (gen_rtx_AND (Pmode, rp, MASK_RETURN_ADDR));
   label = gen_label_rtx ();
 
   /* Check the instruction stream at the normal return address for the
@@ -3544,20 +3542,24 @@
 		 GEN_INT (0xe0400002),
 		 NE, NULL_RTX, SImode, 1, 0);
 
-  /* If there is no export stub then just use our initial guess of
-     -20[frameaddr].  */
+  /* If there is no export stub then just use the value saved from
+     the return pointer register.  */
 
   emit_jump_insn (gen_bne (label));
 
-  /* Here we know that our return address pointer points to an export
+  /* Here we know that our return address points to an export
      stub.  We don't want to return the address of the export stub,
-     but rather the return address that leads back into user code.
-     That return address is stored at -24[frameaddr].  */
+     but rather the return address of the export stub.  That return
+     address is stored at -24[frameaddr].  */
 
-  emit_move_insn (saved_rp, plus_constant (frameaddr, -24));
+  emit_move_insn (saved_rp,
+		  gen_rtx_MEM (Pmode,
+			       memory_address (Pmode,
+					       plus_constant (frameaddr,
+							      -24))));
 
   emit_label (label);
-  return gen_rtx_MEM (Pmode, memory_address (Pmode, saved_rp));
+  return saved_rp;
 }
 
 /* This is only valid once reload has completed because it depends on


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